Filter löschen
Filter löschen

I have problem to make code of deflection of beam

2 Ansichten (letzte 30 Tage)
minji park
minji park am 20 Mai 2015
Beantwortet: Joseph Cheng am 20 Mai 2015
I got this error, 'The variable 'y' appears to change size on every loop iteration. Consider preallocating for speed. please help me ...
function beam()
E = 210* 10^9;
L = 1;
W0= 4000;
I = (0.05 * 0.12^3) / 12;
x=linspace(0,1,101);
for i=1:101
if x(i) < 0.5
y(i) = ((W0* L)/(4 * E * I)) * x(i)^2 - (W0/( 6 * E* I))* x(i)^3;
else
y(i) = ((W0*L)/(4 * E * I)) * x(i)^2 - (W0 / (6 * E * I)) * x(i)^3 + (W0 / (6 *E * I))*(x(i)- L/2)^3;
end
end
plot(x,y);
grid off;
end
Thanks

Antworten (1)

Joseph Cheng
Joseph Cheng am 20 Mai 2015
That is not an error. It is a warning. which based on the size of your function and number of iterations should not be an issue. It is saying if y will grow significantly large it may take some time to add additional data to it unless you pre-allocate the array.

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

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

Start Hunting!

Translated by