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

2 Ansichten (letzte 30 Tage)
daniel
daniel am 8 Dez. 2014
Kommentiert: daniel am 8 Dez. 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

Akzeptierte Antwort

Mohammad Abouali
Mohammad Abouali am 8 Dez. 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 Kommentare
Mohammad Abouali
Mohammad Abouali am 8 Dez. 2014
You are welcome
daniel
daniel am 8 Dez. 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?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by