converting float to integer makes problem
Afficher commentaires plus anciens
My code is:
% Uzunluk(cm)
e=2.25; a=15.75; b=13.5; g=44.25; L=90.50;
%Mesnet yükleri(kg)
C=3750; B=3750; A=6500; D=3750;
%Yayılı yükler(kg/cm)
q1=2*C*(L-e)/(L^2); q2=2*A*(L-a)/(L^2); q3=2*B*(L-a-b)/(L^2); q4=2*D*(L-a-b-g)/(L^2);
%Süperpozisyonla ayrılmış parçaların momentleri(kg.cm)%
%M1=-q1*(x^2)/2; M2=-q1*(x^2)/2+ C*(x-e);
%M3=-q2*(x^2)/2; M4=-q2*(x^2)/2+ A*(x-a);
%M5=-q3*(x^2)/2; M6=-q3*(x^2)/2+ B*(x-a-b);
%M7=-q4*(x^2)/2; M8=-q4*(x^2)/2+ D*(x-e);
% Süperpozisyonla ayrılan parçaların birleştirilmesi sonucu net
% momentler(kg.com)
for x=0:0.025:L
y=int64(40*x)+1;
if (0<=x) && (x<=e)
y
M(y)=-(x^2)/2*(q1+q2+q3+q4);
elseif (e<x) && (x<=a)
y
M(y)=-(x^2)/2*(q1+q2+q3+q4)+C(x-e);
elseif (a<x) && (x<=a+b)
M(y)=-(x^2)/2*(q1+q2+q3+q4)+C(x-e)+A(x-a);
elseif (a+b<x) && (x<=a+b+g)
M(y)=-(x^2)/2*(q1+q2+q3+q4)+C(x-e)+A(x-a)+B(x-a-b);
elseif (a+b+g<x) && (x<=L)
M(y)=-(x^2)/2*(q1+q2+q3+q4)+C(x-e)+A(x-a)+B(x-a-b)+D(x-a-b-g);
end
end
Runner finished first if loop and after that even if it calculates the value of y as 92 it gave me that error:
Array indices must be positive integers or logical values.
Error in untitled2 (line 23)
M(y)=-(x^2)/2*(q1+q2+q3+q4)+C(x-e);
error.
How can i fix that?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!