Incorrect number of inputs or outputs for function linspace

8 件のコメント

clc
clear
x=0:pi/100:2*pi;
y=sin(x);
z=linspace(1,100)
z = 1×100
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
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
/MATLAB/toolbox/matlab/elmat/linspace.m /MATLAB/toolbox/matlab/datatypes/datetime/@datetime/linspace.m % datetime method /MATLAB/toolbox/matlab/datatypes/duration/@duration/linspace.m % duration method /MATLAB/toolbox/parallel/gpu/@gpuArray/linspace.m % gpuArray method /MATLAB/toolbox/parallel/parallel/@distributed/linspace.m % distributed method /MATLAB/toolbox/parallel/parallel/@codistributed/linspace.m % codistributed method /MATLAB/toolbox/parallel/parallel/@codistributor1d/linspace.m % codistributor1d method /MATLAB/toolbox/parallel/parallel/@codistributor2dbc/linspace.m % codistributor2dbc method /MATLAB/toolbox/symbolic/symbolic/@symfun/linspace.m % symfun method
Tanveer Islam
Tanveer Islam 2023 年 6 月 5 日
only these 2 show up.
Tanveer Islam
Tanveer Islam 2023 年 6 月 5 日
Also there is an additional error line for any new code i run although it doesnt involve linspace. it goes like this
Warning: Error updating ButtonImage.
Undefined function 'linspace' for input arguments of type 'double'.
it is repeated multiple times.
for further context, I did cut and paste the r2023 version from the original c folder to g recently.
Star Strider
Star Strider 2023 年 6 月 5 日
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
Torsten 2023 年 6 月 5 日
for further context, I did cut and paste the r2023 version from the original c folder to g recently.
That's temerarious.
Walter Roberson
Walter Roberson 2023 年 6 月 5 日
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
Tanveer Islam 2023 年 6 月 5 日
Doesnt work :/
Torsten
Torsten 2023 年 6 月 5 日
You should follow Walter's advice.

サインインしてコメントする。

回答 (1 件)

chicken vector
chicken vector 2023 年 6 月 5 日

0 投票

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)
ans = logical
1
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.

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品

リリース

R2023a

タグ

質問済み:

2023 年 6 月 5 日

コメント済み:

2023 年 6 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by