The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Error using plot Vectors must be the same lengths.
Replies: 2   Last Post: Mar 19, 2013 9:51 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 69
Registered: 2/22/12
Re: Error using plot Vectors must be the same lengths.
Posted: Mar 19, 2013 7:16 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Chris " <> wrote in message <khi704$cp6$>...
> So I am somewhat new to matlab and am getting this error when i run this code: Error using plot Vectors must be the same lengths. I believe everything in my code is correct just it wont run. PLEASE HELP!
> clf
> close all
> s=0:0.1:6;
> L=8.4;
> P=800;
> B=[P*cosd(20); -P*sind(20); 0];
> for i=1:length(s)
> x(i)=(L^2-49+(14*s(i)))/(2*L);
> y(i)=sqrt(x(i)^2-s(i)^2);
> A1=[ 1, 0, (((7-s(i))/(L-x(i)))-(s(i)/x(i)))];
> A2=[ 0, 1, ((y(i)/(L-x(i)))+(y(i)/x(i)))];
> A3=[ 5.1, 3.5, ((7*y(i))/x(i))];
> A=[ A1; A2; A3];
> T(:,i)=A\B;
> end
> figure
> plot(s,T(1,:),s,T(2,:),s,T(3,:),'LineWidth',1)
> xlabel('s[Meters]','FontSize',16)
> ylabel('Tension[Newtons]','FontSize',16)
> title('Tension in the rope as a function of s','FontSize',16)

>> help plot

PLOT(X1,Y1,S1,X2,Y2,S2,X3,Y3,S3,...) combines the plots defined by
the (X,Y,S) triples, where the X's and Y's are vectors or matrices
and the S's are strings.

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.