Conversion to double from struct is not possible.

11 ビュー (過去 30 日間)
Yandong Ji
Yandong Ji 2017 年 10 月 22 日
コメント済み: Massimo Lucia 2020 年 5 月 5 日
{
x=0:0.01:2*pi;
y=sin(x);
figure;
plot(x,y,'r');
xlim([0 2*pi]);
ax=gca;
set(ax,'xtick',[0 pi 2*pi],'xticklabel',{'0','1','2'});
set(ax,'ytick',-1:.5:1);
}
it says error using 'set', wondering what's the mistake
  1 件のコメント
Cedric
Cedric 2017 年 10 月 22 日
編集済み: Cedric 2017 年 10 月 22 日
What happens if you evaluate
>> clear all
and then copy-paste exactly this code in the command window? If it works you may have shadowed something earlier; if it doesn't work, which version of MATLAB are you using?

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

回答 (4 件)

Image Analyst
Image Analyst 2017 年 10 月 22 日
I don't think you can enclose a block of 8 lines in braces like you did. With them in there I get a different error message than you did. If I take them out, I get no error message at all.
Also, you can use xticks() and yticks() and xticklabels() and yticklabels() instead of set() if you have R2016b version of MATLAB or later.
  1 件のコメント
Cedric
Cedric 2017 年 10 月 22 日
編集済み: Cedric 2017 年 10 月 22 日
I apologize ImageAnalyst, I edited out the {} because I thought that the OP had used them for formatting code in the forum. I will put them back so people understand.

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


Yandong Ji
Yandong Ji 2017 年 10 月 22 日
Thanka, my MATLAB is 2015b. I found it can only read ax.XTick or set(ax,'XTick',[0 pi 2*pi]) instead of ax.xtick, just the problem of caps.

Yandong Ji
Yandong Ji 2017 年 10 月 22 日
you are both right. Some hours ago I met all the problems you mentioned. Besides, just now I used xtick and it showed 'No public property xtick exists for class matlab.graphics.axis.Axes.'.

Massimo Lucia
Massimo Lucia 2020 年 5 月 5 日
Can you please help me with this error message?
Conversion to double from struct is not possible.
Error in STABLE (line 79)
qs(i,:) = qSol;
Find attached the STABLE.m
  2 件のコメント
Image Analyst
Image Analyst 2020 年 5 月 5 日
Start a new question with this. In the meantime, put this on it's own line just before that line 79 and see what fields get listed in the command window:
qSol % Don't use a semicolon!

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

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!