Error using plot--vectors must be the same lengths?

1 visualización (últimos 30 días)
Kelsey
Kelsey el 22 de Abr. de 2014
Comentada: the cyclist el 22 de Abr. de 2014
Why am I getting the error message, "Error using plot Vectors must be the same lengths"? This code worked fine before I added a few more data points… Thank you in advance! :)
% Load Horiz.Disp. Vert.Disp.
A=[0.000000E+0 0.000000E+0 0.000000E+0
3.735352E-1 -5.517578E-3 -3.906250E-4
5.489746E-1 -1.005859E-2 -9.765625E-5
5.575684E-1 -1.054687E-2 7.812500E-4
5.644531E-1 -1.113281E-2 1.708984E-3
6.968750E-1 -1.381836E-2 2.734375E-3
9.428223E-1 -1.835937E-2 2.734375E-3
1.182324E+0 -2.192383E-2 4.394531E-3
1.416846E+0 -2.827148E-2 4.150391E-3
1.622949E+0 -3.500977E-2 3.906250E-3
1.815039E+0 -4.213867E-2 5.126953E-3
2.005273E+0 -5.039062E-2 5.664063E-3
2.201904E+0 -5.966797E-2 5.908203E-3
2.406152E+0 -7.031250E-2 5.859375E-3
2.622949E+0 -8.139648E-2 6.005859E-3
2.858691E+0 -9.526367E-2 5.957031E-3
3.104980E+0 -1.117676E-1 6.494141E-3
3.371484E+0 -1.316406E-1 7.226563E-3
3.663330E+0 -1.607422E-1 6.787109E-3
3.968652E+0 -1.978027E-1 7.666016E-3
4.311963E+0 -2.585937E-1 7.226563E-3
4.648584E+0 -3.464844E-1 8.251953E-3
4.933789E+0 -4.650879E-1 8.984375E-3
5.160156E+0 -6.127930E-1 9.472656E-3
5.314648E+0 -7.623535E-1 9.423828E-3
5.421826E+0 -9.119141E-1 9.814453E-3
5.497217E+0 -1.054199E+0 1.054688E-2
5.550635E+0 -1.184229E+0 1.079102E-2
5.592627E+0 -1.308594E+0 1.127930E-2
5.625293E+0 -1.420264E+0 1.191406E-2
5.677246E+0 -1.631250E+0 1.269531E-2
5.710596E+0 -1.820898E+0 1.333008E-2
5.735498E+0 -1.994336E+0 1.420898E-2
5.754199E+0 -2.154346E+0 1.552734E-2
5.777881E+0 -2.449365E+0 1.650391E-2
5.781934E+0 -2.584668E+0 1.728516E-2
5.781396E+0 -2.712500E+0 1.796875E-2
5.778418E+0 -2.836328E+0 1.948242E-2
5.776172E+0 -2.897314E+0 2.011719E-2
5.765283E+0 -3.072803E+0 2.109375E-2
5.759521E+0 -3.127002E+0 2.207031E-2
5.754980E+0 -3.183545E+0 2.304688E-2
5.733252E+0 -3.396484E+0 2.456055E-2
5.717334E+0 -3.498437E+0 2.558594E-2
5.684521E+0 -3.697021E+0 2.705078E-2
5.664746E+0 -3.790869E+0 2.783203E-2
5.633740E+0 -3.931055E+0 2.861328E-2
5.621533E+0 -3.974951E+0 2.934570E-2
5.598584E+0 -4.064502E+0 3.007813E-2
5.585693E+0 -4.108057E+0 3.081055E-2
5.573096E+0 -4.152197E+0 3.159180E-2
5.535010E+0 -4.279150E+0 3.247070E-2];
load=(A(:,1)).*100;
HorizDisp=abs((A(:,2)).*0.19574);
VertDisp=abs((A(:,3)).*1.724);
l=length(load);
yield=40000; %yield stress = 40 ksi
b=.125; %b = t = thickness of rod
h=1; %h = w = width of rod
L=9.875; %L = length of rod (subtracted out 2 in from 11.875)
E=10000000; %elastic modulus of Al 6061-T6
I=h*(b^3)/12; %Moment of Intertia
P=E*I*4*pi*pi/(L*L); %Buckling (or "critical") Load
disp(P) %Display value of Buckling Load
for n=1:l
loadnorm(n)=load(n)/P; %Normalize applied load by dividing by P
end
plot(VertDisp,loadnorm);
  1 comentario
the cyclist
the cyclist el 22 de Abr. de 2014
Side note: You should avoid naming a variable "load", because that is a MATLAB keyword.
[Not related to your present difficulty, most likely, but just good programming practice.]

Iniciar sesión para comentar.

Respuestas (2)

the cyclist
the cyclist el 22 de Abr. de 2014
This code ran to completion for me.
  1 comentario
Kelsey
Kelsey el 22 de Abr. de 2014
So you got the plot out?? I wonder why I'm not getting it… :(

Iniciar sesión para comentar.


Joseph Cheng
Joseph Cheng el 22 de Abr. de 2014
Plotted with mine as well. Kelsey can you tell us what dimensions (mxn) VertDisp and loadnorm are that you have in the work space?
Have you attempted to clear the workspace. Perhaps in your trouble shooting a dimension in either variable got screwed up.
  2 comentarios
Kelsey
Kelsey el 22 de Abr. de 2014
They're all 52x1 matrices (vectors)! I removed the for loop, and now it works. How do I clear the workspace?
Thank you for your help!
the cyclist
the cyclist el 22 de Abr. de 2014
Type "clear" at the command prompt.

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by