Implementing arrayfun for the yline function

조회 수: 2 (최근 30일)
KostasK
KostasK 2020년 6월 11일
댓글: KostasK 2020년 6월 11일
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일
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개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by