Borrar filtros
Borrar filtros

Trying to multiply Matrices

1 visualización (últimos 30 días)
Mark Prentice
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

Respuesta aceptada

Walter Roberson
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
N = 201
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
B_bar = 0
A =
(1,1) -2 (2,1) 1 (1,2) 1 (2,2) -2 (3,2) 1 (2,3) 1 (3,3) -2 (4,3) 1 (3,4) 1 (4,4) -2
ans = 'double'
0.0000 + 1.0000i
Array indices must be positive integers or logical values.
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)

Más respuestas (0)

Categorías

Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by