Azzera filtri
Azzera filtri

I have problem to make code of deflection of beam

2 visualizzazioni (ultimi 30 giorni)
minji park
minji park il 20 Mag 2015
Risposto: Joseph Cheng il 20 Mag 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

Risposte (1)

Joseph Cheng
Joseph Cheng il 20 Mag 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.

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Tag

Non è stata ancora inserito alcun tag.

Community Treasure Hunt

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

Start Hunting!

Translated by