Wrong sine plot when styling it

14 次查看(过去 30 天)
I was playing with the tutorial of Matlab. I've written this code:
x = linspace(0, 2*pi);
y = sin(x);
plot(x, y)
And I obtain the right plot:
right
But then I use the following command:
plot(x, y, "r--")
And I obtain this weird plot:
wrong
What I'm doing wrong?
  2 个评论
Steven Lord
Steven Lord 2024-5-7
Let's check which plot function you're calling in each case.
x = linspace(0, 2*pi);
y = sin(x);
which plot(x, y)
built-in (/MATLAB/toolbox/matlab/graph2d/plot)
which plot(x, y, "r--")
built-in (/MATLAB/toolbox/matlab/graph2d/plot)
In particular, I'm wondering if something added an overload of plot for the string data type to the MATLAB path.
And just for completeness, what does the next line of code show and what is the output of the which call that follows it?
plot(x, y, 'r--')
which plot(x, y, 'r--')
built-in (/MATLAB/toolbox/matlab/graph2d/plot)
Daniele Lupo
Daniele Lupo 2024-5-7
I close and reopened matlab and the problem does not appear anymore. I don't see anything wrong with the command history, and the which command gives me always built-in (C:\Program Files\MATLAB\R2022b\toolbox\matlab\graph2d\plot)...

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息

标签

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by