![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/364528/image.jpeg)
What am I doing wrong?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I am following a line of code from a MATLAB book line for line but keep getting this error code and I'm not understanding why.
>> f = @(mu,x) mu*x-x.^3;
>> x = linspace(-5,5);
>> f_many = [f(-5,x) f(0,x) f(5,x) f(45,x)];
>> plot(x,f_many)
Error using plot
Vectors must be the same length.
0 Kommentare
Antworten (1)
Abdolkarim Mohammadi
am 22 Sep. 2020
Bearbeitet: Abdolkarim Mohammadi
am 22 Sep. 2020
For drawing multiple line plots at once, you should have one column vector for each line. You just need to have x as a column vector. f_many will also be an array with four columns.
x = linspace (-5,5)';
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/364528/image.jpeg)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!