| Error: Unexpected MATLAB operator. Why, please?

2 ビュー (過去 30 日間)
mahipal komandla
mahipal komandla 2017 年 5 月 30 日
回答済み: Steven Lord 2017 年 5 月 30 日
plot(plot::Spherical([1, u, v], u = 0..2*PI, v = 0..PI))
plot(plot::Spherical([1, u, v], u = 0..2*PI, v = 0..PI))
| Error: Unexpected MATLAB operator.
I am using matlab version 7.14.0.739 (R2012a) . Why error is coming. Please help me
>> version ans = 7.14.0.739 (R2012a)
  1 件のコメント
dpb
dpb 2017 年 5 月 30 日
Bad syntax all over...no idea where the line came from, but just isn't Matlab-y syntax at all.
There isn't any '::' operator in Matlab, plot syntax is basically
plot(x,y)
where x,y are independent/dependent variables to be plotted, Assignment in a function call isn't how named parameters are used in Matlab and the '..' sequence isn't legal if were besides. The builtin function returning the value for pi is pi in Matlab not PI just for starters...

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

回答 (1 件)

Steven Lord
Steven Lord 2017 年 5 月 30 日
Whenever you see :: or .. (without a third period to make an ellipsis) in a command, it's likely a command intended to be used in a MuPAD Notebook not in a MATLAB function or at the MATLAB Command Prompt.
There isn't really a direct equivalent of the plot::Spherical command that will work in MATLAB. Close would be to generate your data in spherical coordinates, use sph2cart to convert those coordinates to Cartesian, then use surf or a similar function to plot the data using Cartesian coordinates.

Community Treasure Hunt

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

Start Hunting!

Translated by