1

everybody,

I have a new problem with matlab, I want to generate a graph using Plot !

I wrote that:

X=[0, 2.5];
P = 0.1 * ones(N,11);
N=length(X);
for n=1:N
    for t=1:10
    P(n,t+1)=X(n)*P(n,t)*[1-P(n,t)];
    end
end
plot(t,P)

But again the computer answer me that :

??? Error using ==> plot
Vectors must be the same lengths.

Error in ==> test at 10
plot(t,P) 

I do not have any idea of why ?

2
  • 1
    Please format your question correctly; you can sort out the code by selecting it and clicking the button marked {} in the editor. Commented Dec 11, 2011 at 13:16
  • I will, sorry to disturb you by the way... Commented Dec 11, 2011 at 13:33

1 Answer 1

2

The variable t in your plot command is no a vector but just the scalar 10. You have to call the plot command instead with

plot(1:11,P);
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks a lot ! Do you know How can I do something like thaht : hpics.li/57b346a if I substitute X by Psi, because Now All my graphs are together...
You have to use the subplot command for this type of plots. Take a look at the Matlab help with doc subplot for more details.
I think you want plot(0:10, P), but I can't be sure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.