필터 지우기
필터 지우기

Index exceeds the number of array elements (1).

조회 수: 1 (최근 30일)
Vicente Fuentealba Reyes
Vicente Fuentealba Reyes 2020년 10월 31일
이동: Walter Roberson 2023년 9월 27일
I=(b*h^3)/12; % Inercia se mide en cm^4, Variable de salida
Unrecognized function or variable 'b'.
x=0:0.1:L; %Vector
def=zeros(length(x),length(F)+1);
for j=1:length(F)
for i=1:length(x)
if x(i)>=a(j)
def(i,j)=((F(j)*b(j))/(6*L*E*I))*((L/b(j))*(x(i)-a(j))^3-x(i)^3+(L^2-b(j)^2)*x(i));
else
def(i,j)=((F(j)*b(j))/(6*L*E*I))*(-x(i)^3+(L^2-b(j)^2)*x(i));
end
end
end
def(:,end)=sum(def,2);
me ocurre luego del else, esa formula, me da error por algunar razon, nesecito ayuda, ya que es por una tarea
  댓글 수: 1
Walter Roberson
Walter Roberson 2023년 9월 27일
Approximate translation:
It happens to me after the else, that formula, it gives me an error for some reason, I need help, since it is for a task

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2023년 9월 27일
이동: Walter Roberson 2023년 9월 27일
format long g
h = rand() %guess
h =
0.417948953996748
L = rand() * 3 %guess
L =
1.32388434608202
F = sort(rand(1,7)) %guess
F = 1×7
0.11991245962135 0.29570499617597 0.415964024718241 0.693165544877611 0.702821324822456 0.725661942718158 0.98651689150941
a = rand(size(F)) %guess
a = 1×7
0.602261901516086 0.0802892332996559 0.115357856160582 0.94879157875644 0.167653007634221 0.304942826817748 0.894580810077379
b = rand(size(F)) %guess
b = 1×7
0.0640251615177048 0.154027841888933 0.480714567113372 0.629086724012843 0.00769341226588571 0.585933615959605 0.545553092415119
E = rand() * 10 %guess
E =
2.42930294432061
I=(b*h^3)/12; % Inercia se mide en cm^4, Variable de salida
x=0:0.1:L; %Vector
def=zeros(length(x),length(F)+1);
for j=1:length(F)
for i=1:length(x)
if x(i)>=a(j)
def(i,j)=((F(j)*b(j))/(6*L*E*I))*((L/b(j))*(x(i)-a(j))^3-x(i)^3+(L^2-b(j)^2)*x(i));
else
def(i,j)=((F(j)*b(j))/(6*L*E*I))*(-x(i)^3+(L^2-b(j)^2)*x(i));
end
end
end
Error using /
Matrix dimensions must agree.
def(:,end)=sum(def,2);
We deduce that b must be a vector at least as long as F is, or else you would not index b(j) in the code.
But if b is a vector then since I = b*h^3 then I would have to be a vector the same size as b.
But you have / (6*L*E*I) and with I being a vector, the denominator would have to be a vector -- unless, that is, that L*E happens to be a row matrix and b happens to be a column matrix, in which case L*E*I could be a request for algebraic multiplication that collapsed two vectors into a scalar. But L is used as the upper bound for the for j loop, so it is probably not a vector... and we see no other indication that E might be a vector. Oh and the code has L^2 which could only work if L is a square array (including scalar) because ^ is matrix power, not element-by-element power
Could it be that ./ is needed instead of / ? If we work though using the fact that L must be a square matrix for L^2 to be valid, we can see that if 6*L*E*I is non-scalar and ./ is used, then the right hand side of the assignments to def(i,j) could not possibly be scalar.
Nothing much makes sense unless b and F are both scalars even though they are indexed in the code.

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by