Need help with plotting a graph on matlab- linewidth
1 回表示 (過去 30 日間)
古いコメントを表示
I was wondering if someone could tell me why I get this error returning:
Error using plot
String argument is an unknown option.
Whenever I try to add the 'linewidth',2 parameter for the plot function.
Here's my code:
h1 = sin(x)+x^2/7-0.3;
g1 = cosh(0.2*x);
x_values = 0:.04:4;
y_values=subs(h1,x_values);
figure(2);clf reset
plot(x_values,y_values,'b:',x_values,subs(g1,x_values),'r');
title('Plot of two functions');
xlabel('x-axis');
ylabel('y-axis');
legend('Plot of h1','plot of g1')
The line specifically I need help with is:
plot(x_values,y_values,'b:',x_values,subs(g1,x_values),'r');
Adding in 'linewidth',2 here produces the error I mentioned before
plot(x_values,y_values,'b:','linewidth',2,x_values,subs(g1,x_values),'r');
Any help would be massively appreciated!
0 件のコメント
採用された回答
Thorsten
2014 年 10 月 14 日
The help for plot states that
"The X,Y pairs, or X,Y,S triples, can be followed by
parameter/value pairs to specify additional properties
of the lines."
But this is not true if you have multiple x, y values in one plot command. In this case you have to split them like
plot(x_values,y_values,'b:','linewidth',2)
hold on
plot(x_values,subs(g1,x_values),'r');
その他の回答 (1 件)
Robert Cumming
2014 年 10 月 14 日
If you split it over two plot commands it will work:
plot(x_values,y_values,'b:','linewidth',2)
plot(x_values,subs(g1,x_values),'r');
When passing in extra arguments - you cant then pass in other x, y pairs.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Discrete Data Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!