I am getting error in this program. Please suggest the corrections.

3 ビュー (過去 30 日間)
Kartik Lanjewar
Kartik Lanjewar 2021 年 11 月 17 日
回答済み: Alan Stevens 2021 年 11 月 17 日
% for constant doc
c = [1 2 2 3 4 5 6 7];
r1 = [1.9981 3.9966 7.9922 15.9863 31.5551 63.7318 102.771];
r2 = [1.9988 3.9966 7.9806 15.9111 31.9588 63.5392 128.4018];
r3 = [1.9989 3.9979 7.9958 15.9843 31.9694 63.9415 143.27];
plot(c,r1,'--bo',c,r2,'--ro',c,r3,'--go');
xlabel('Classes');
ylabel('max rrate');
title('graph b/w classes & max rrate');
legend('premonsoon','postmonsoon','monsoon');
  2 件のコメント
Adam
Adam 2021 年 11 月 17 日
If you are getting an error please include the full error text in the question so we don't have to guess what it is.
Kartik Lanjewar
Kartik Lanjewar 2021 年 11 月 17 日

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

採用された回答

Star Strider
Star Strider 2021 年 11 月 17 日
First, save the function as ‘graph_prog.m’ (note underscore). If I remember correctly, MATLAB .m file names cannot include spaces. (That may have changed, however I never include spaces in my .m file names, so I’ve not tested it.)
% for constant doc
c = [1 2 3 4 5 6 7];
r1 = [1.9981 3.9966 7.9922 15.9863 31.5551 63.7318 102.771];
r2 = [1.9988 3.9966 7.9806 15.9111 31.9588 63.5392 128.4018];
r3 = [1.9989 3.9979 7.9958 15.9843 31.9694 63.9415 143.27];
plot(c,r1,'--bo',c,r2,'--ro',c,r3,'--go');
xlabel('Classes');
ylabel('max rrate');
title('graph b/w classes & max rrate');
legend('premonsoon','postmonsoon','monsoon', 'Location','best');
After removing the duplicated 2 in ‘c’ it works. (Duplicates are allowed, however with the duplicate, the vector lengths did not match.)
.

その他の回答 (1 件)

Alan Stevens
Alan Stevens 2021 年 11 月 17 日
Change
c = [1 2 2 3 4 5 6 7];
to
c = [1 2 3 4 5 6 7];

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by