Why can't I plot a simple line???

2 vues (au cours des 30 derniers jours)
daniel
daniel le 8 Déc 2014
Commenté : daniel le 8 Déc 2014
I am trying to change the limits of my axis, and just draw a line through x = 0. But for some reason if I only specify a solid line in my LineStyle, matlab wont plot anything, if I choose anything else it works fine i.e *,o,>,<.... I will just do a simple example to illustrate my point.
>> figure
>> hold on
>> grid on
>> set(gca,'LineWidth',1)
>> axis([-10,10,0,30]);
>> plot(0,0:1:30,'r-') %% this produces nothing
>> plot(0,0:1:30,'r-*')%% this and everything else does..
>> plot(0,0:1:30,'r-o')
>> plot(0,0:1:30,'r->')
>> plot(0,0:1:30,'r-<')
Any idea why? Any help will be appreciated.
-D

Réponse acceptée

Mohammad Abouali
Mohammad Abouali le 8 Déc 2014
Well, if you change
plot(0,0:1:30,'r-')
to
plot(zeros(1,31),0:1:30,'r-')
it would generate a line.
However, if you want to change your axis limit that is not a proper approach
Use
xlim([minXAxisValue maxXAsixValue])
ylim([minYAxisValue maxYAsixValue])
  3 commentaires
Mohammad Abouali
Mohammad Abouali le 8 Déc 2014
You are welcome
daniel
daniel le 8 Déc 2014
Mohammad, suppose I want to plot a line across y = -15.
plot(0:1:100,-15.*ones(101,1),'r-')
will produce the line but is there a cleaner way of doing this?

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by