Plotting 4-D arrays in 2-D graph

1 回表示 (過去 30 日間)
Chun Zhang
Chun Zhang 2019 年 10 月 1 日
編集済み: Jon 2019 年 10 月 1 日
Hello, I am a newbie to matlab. I have a question about generating a plot.
My code is as follows. The irfStd is a 3x20x800x33 4-D matrix. The size(irf1,4) = 800.
I am wondering why I can't generate plot using this code and matlab kept reporting 'Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses.'
Thanks in advance.
lb=floor(size(irf1,4)*.16)+1; % lower band
ub=ceil(size(irf1,4)*.84)+1; % upper band
plot(1:20,squeeze(median(irfStd(2,:,:,11),3)),'k',1:20,squeeze(irfStd(2,:,[lb ub],11)),'--k')...
axis tight, title('Inflation')

回答 (1 件)

Jon
Jon 2019 年 10 月 1 日
編集済み: Jon 2019 年 10 月 1 日
The axis command and title command are not part of the plot command but you continued them on the same line without a separator. Just replace your last few lines with
plot(1:20,squeeze(median(irfStd(2,:,:,11),3)),'k',1:20,squeeze(median(irfStd(2,:,[lb ub],11),3))','--k')
axis tight,
title('Inflation')
  2 件のコメント
Chun Zhang
Chun Zhang 2019 年 10 月 1 日
Thank you for your quick answer but these commands work quite well in other plots.
Jon
Jon 2019 年 10 月 1 日
編集済み: Jon 2019 年 10 月 1 日
The commands plot, axis, and title must either be separated by commas, or by newlines.
When it worked you probably had a comma between '--k') and the ...
'--k'),...
or before the word axis
...
,axis tight,title('Inflation')

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

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by