フィルターのクリア

How to plot a different symbol and symbol line for each plot inside this loop?

20 ビュー (過去 30 日間)
juan sanchez
juan sanchez 2021 年 11 月 27 日
コメント済み: DGM 2021 年 11 月 28 日
for j=1:3
symbolList = ['o', 'x', 's', 'd','.', '^', 'v', '>', '<', '*','p','h','+'];
symbol = sprintf('r%s-', symbolList(mod(j-1,length(symbolList))+1));
plot(a(1,:),b(1,:).*25.4, symbol, 'LineWidth', 0.1);
hold on
plot(c(1,:),d(1,:).*25.4, symbol, 'LineWidth', 0.1);
hold on
plot(e(1,:),f(1,:).*25.4, symbol, 'LineWidth', 0.1);
hold on
end %for 3 plots
  2 件のコメント
Walter Roberson
Walter Roberson 2021 年 11 月 28 日
What difficulty are you encountering?
juan sanchez
juan sanchez 2021 年 11 月 28 日
Thank you, I wanted to numerically add in ascendinr order the next subsequent symbol for the 1st, 2nd and 3rd plots but I was confused. The accepted answer herein explains it better.

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

採用された回答

DGM
DGM 2021 年 11 月 28 日
編集済み: DGM 2021 年 11 月 28 日
I'm not sure why you're using a loop to create the same plots three times with different symbols. Are there other columns (of a,b,c etc) that need to be plotted as the loop increments?
Alternatively, do you mean to simply plot each of these three things once, but automatically using a unique symbol for each?
If that's the case, and your data doesn't lend itself to indexing, then you might consider turning symbol into a function. That way you can just do something like this:
symbolList = ['o', 'x', 's', 'd','.', '^', 'v', '>', '<', '*','p','h','+'];
symbol = @(k) sprintf('r%s-', symbolList(mod(k-1,length(symbolList))+1));
hold on
plot((1:10)+5, symbol(1), 'LineWidth', 0.1);
plot((1:10)+10, symbol(2), 'LineWidth', 0.1);
plot((1:10)+15, symbol(3), 'LineWidth', 0.1);
Obviously I'm just using placeholder data here.
  2 件のコメント
juan sanchez
juan sanchez 2021 年 11 月 28 日
Thank you very much. I was confused and you clearly explained in words what I wanted to do. I guess I can do something similar for line type too. I need more practice to fully understand these functions. Great answer!!
DGM
DGM 2021 年 11 月 28 日
no problem

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by