Implementing arrayfun for the yline function

Hi there,
I have been trying to implement arrayfun for the function yline. In specific I have the following code:
figure
arrayfun(@(x, y) yline(x, y), [4 5], {'--', '-.'})
However, I get the following error
Error using colstyle
Requires a string scalar or a character vector argument.
I suspect it is comming from the {'--', '-.'} argument, since if I exclude it and simply have arrayfun(@(x) yline(x), [4 5]), then it works as expected. However, I still need to differentiate the linestyle of the two ylines, and I wouldn't like to mess with for loops. So what am I doing wrong in this case?
Thanks for your responses in advance.

 採用された回答

madhan ravi
madhan ravi 2020 年 6 月 11 日

0 投票

figure(1)
arrayfun(@(x, y) yline(x, y), [4 5], ["--", "-."])
ylim([0,6])

1 件のコメント

KostasK
KostasK 2020 年 6 月 11 日
I see, the double quotes did the trick. Thanks!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMarine and Underwater Vehicles についてさらに検索

質問済み:

2020 年 6 月 11 日

コメント済み:

2020 年 6 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by