フィルターのクリア

making the code run in certain condition

2 ビュー (過去 30 日間)
Joo Seo Lee
Joo Seo Lee 2020 年 9 月 18 日
回答済み: Gouri Chennuru 2020 年 9 月 22 日
for i=1:length(yearU)
use=find(year==yearU(i));
Rad_s=Rad(use);
Rad_s1=Rad_s(~isnan(Rad_s));
Rad_s1_sort=sort(Rad_s1, 'descend');
ext_Rad(i,1)=mean(Rad_s1_sort(1:7));
end
figure (7)
plot(yearU, ext_Rad, '-or');
xlabel('Time'); ylabel('wettest five day temperature (C)');
set(gcf, 'PaperUnits', 'inches', 'PaperPosition', [0 0 12 8]);
print(gcf,'-dpng','-r300', ['fig7.png']);
at here, i want to give a make this run when the number of Rad is 5 or more. How should I write the code that gives this condition?
  3 件のコメント
Joo Seo Lee
Joo Seo Lee 2020 年 9 月 18 日
Yes. How should I write the code?
Rik
Rik 2020 年 9 月 18 日
It sounds like you need an if statement. If you don't know how to use that you will probably benefit from a Matlab tutorial. I would suggest Onramp, which is provided for free by Mathworks.

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

回答 (1 件)

Gouri Chennuru
Gouri Chennuru 2020 年 9 月 22 日
Hi,
You can use the if condition available in MATLAB in order to execute the set of statements under certain condition.
As a workaround, place the if statement with the condition numel(ext_Rad)>=5 to execute the set of statements.
if numel(ext_Rad)>=5
figure (7)
plot(yearU, ext_Rad, '-or');
xlabel('Time'); ylabel('wettest five day temperature (C)');
set(gcf, 'PaperUnits', 'inches', 'PaperPosition', [0 0 12 8]);
print(gcf,'-dpng','-r300', ['fig7.png']);
end
Hope this Helps !

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by