Incorrect number of inputs or outputs for function linspace
Show older comments

8 Comments
clc
clear
x=0:pi/100:2*pi;
y=sin(x);
z=linspace(1,100)
The default for linspace() is 100 points.
If your linspace() is complaining then somehow you are getting a different linspace. What shows up for
which -all linspace
Tanveer Islam
on 5 Jun 2023
Tanveer Islam
on 5 Jun 2023
Star Strider
on 5 Jun 2023
It should be returning something similar to those in Walter’s Comment.
Run these from a script or your Command Window:
restoredefaultpath
rehash toolboxcache
Then try your original code again and report the results.
Torsten
on 5 Jun 2023
for further context, I did cut and paste the r2023 version from the original c folder to g recently.
That's temerarious.
Walter Roberson
on 5 Jun 2023
The MATLAB that you copied from C: to G: recently appears to not be complete. If you need it to be stored in G: drive you should remove the G: version and uninstall from C: and then use the installer to install into G: directly.
Tanveer Islam
on 5 Jun 2023
Torsten
on 5 Jun 2023
You should follow Walter's advice.
Answers (1)
Even if it is a matter of personal taste, for unit steps I usually prefer to do:
z1 = 1 : 100;
Nontheless, this should also work:
z2 = linspace(1, 100);
isequal(z1, z2)
Are you sure didn't create a function called linspace?
Have you tried to reset the path and clear the Workspace?
Try to restart Matlab and run it again.
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
