Trying to multiply Matrices
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Mark Prentice
el 7 de Ag. de 2021
Respondida: Walter Roberson
el 8 de Ag. de 2021
Hey there,
I'm trying to pultiple some matricies to output a new matrix or array of Y but seem to be getting an error. "Array indices must be positive integers or logical values." I only need values at 4 evenly spaced interior points but cant seem to tell the equation to only look at 4 values instead of all 199. Anything help thank you.
close all;
clear all;
clear;
L=10; %given
EI=1900; %given
q=-0.6; %given
dx=0.05;%desired grid spacing
N = 1+L/dx
X = linspace(0,10,N)';
Y=X*0;%inital condistion
for n = 1 : length(X)-2 % the # of interrior points
%this creates B bar which is all known at every time step
B_bar(n,:) = (((q.*X(n).*(X(n)-L))*(dx^2))/(EI*2))
A=gallery('tridiag' , 4 , 1,-2,1)
Y(i)=A'.*B_bar
0 comentarios
Respuesta aceptada
Walter Roberson
el 8 de Ag. de 2021
L=10; %given
EI=1900; %given
q=-0.6; %given
dx=0.05;%desired grid spacing
N = 1+L/dx
X = linspace(0,10,N)';
Y=X*0;%inital condistion
for n = 1 : length(X)-2 % the # of interrior points
%this creates B bar which is all known at every time step
B_bar(n,:) = (((q.*X(n).*(X(n)-L))*(dx^2))/(EI*2))
A=gallery('tridiag' , 4 , 1,-2,1)
class(i)
whos i
disp(i)
Y(i)=A'.*B_bar
end
You are storing into Y(i) but i has value complex(0,1) .
You did not assign a value to i, so it has its default value, which is sqrt(-1) . The default value of j is also sqrt(-1)
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!