Professional Documents
Culture Documents
Vote
0
StairPlotproblem
AskedbyPatrickSaegesseron19Dec2011
22views(last30days)
Ihavefourdatapointsalongadateaxis,whichIwanttoplotasastairs.
thedataare
Data = [9;9;10;9]
thedatesareinchronologicalorder,butdon'treallymaterhereIthink.
Myproblemisthatwhenplottingas
stairs(Dates,Data)
matlabmarkssixdatapointsinsteadoftheactualfour.Irealizethatthisisnecessaryinordertodothecorners,
butisn'tthereawaytokeepthelinewhilehavingthemarkersonlyontheactualdatapoints.
Andmoreimportantly,asitisnowtheplotrisesto10(andhasamarkerat9atthesametime)beforethe
matchingdate,andgoesbackto9atthetimeitshouldbe10.
IsthereanypropertyIneedtochangeinordertogettheoutputIwant?
0Comments
Tags
MATLABAnswers
matlab statisticstoolbox stair plot
http://www.mathworks.com/matlabcentral/answers/24304stairplotproblem?requestedDomain=www.mathworks.com 1/4
23/6/2016 StairPlotproblemMATLABAnswersMATLABCentral
Products
Noproductsareassociatedwiththisquestion.
RelatedContent
1Answer
Vote
0
Link
AnswerbyFangjunJiangon19Dec2011
Iguessthatiswhatthewaystairs()isdesigned.
Toansweryourfirstpartofthequestion,youprobablyneedtodotwosteps.
%%
Data=[9;9;10;9];
figure;
stairs(Data);
hold on;
plot(Data,'*');
axis([0 5 8 11]);
Iamnotveryclearaboutyoursecondpartofthequestion.Maybethis?
%%
Data=[9;9;10;9];
figure;
stairs([Data;Data(end)]);
hold on;
plot(Data,'*');
axis([0 5 8 11]);
MATLABAnswers
2Comments
http://www.mathworks.com/matlabcentral/answers/24304stairplotproblem?requestedDomain=www.mathworks.com 2/4
23/6/2016 2Comments StairPlotproblemMATLABAnswersMATLABCentral
PatrickSaegesseron19Dec2011
Thanksforyouranswer.SorrythatIwasn'ttooclear.
I'llhavetotry,butIthinkthefirstpartpartshouldworkintwostepsasyoudescribed.Idon't
understandwhyitmarkspointsthatarenotinthedataset,butasyousaid,itmaythewayitis
designed.
Regardingthesecondquestion,usingyouraxispoints,IwanttheplottoreflectthattheDateis
alwaysthefirstpointintimeonagivenlevel,andtheyvalueremainsthereuntilaneweventoccurs.
Currently,thestepfromy=9toy=10takesplaceatx=5,remainsthereonx=8anddropstoy=9there.
ThusIhavetwopointswherey=10andy=9atthesamexvalue,oneatx=5,theotheratx=8.
Iwouldliketohaveitrisetoy=10atx=8andremainthereuntilx=11,whereitthendropsback.
FangjunJiangon19Dec2011
Ithinkyoumayhavesomeinconsistencydescribingyourdatainyourcomments.Icanthinkofaway
toshowthedropofyfrom10to9atx=8,butIdon'tseewhyx=11comestothepicture.
%%
Data=[99109]
x=[1358]
figure
stairs([xx(end)+1],[DataData(end)])
holdon
plot(x,Data,'*')
axis([010811])
MATLABandSimulinkresourcesforArduino,LEGO,andRaspberryPi
Learnmore
MATLABAnswers
DiscoverwhatMATLABcandoforyourcareer.
http://www.mathworks.com/matlabcentral/answers/24304stairplotproblem?requestedDomain=www.mathworks.com 3/4
23/6/2016 StairPlotproblemMATLABAnswersMATLABCentral
Opportunitiesforrecentengineeringgrads.
ApplyToday
MATLABAcademy
NewtoMATLAB?
LearnMATLABtoday!
19942016TheMathWorks,Inc.
MATLABAnswers
http://www.mathworks.com/matlabcentral/answers/24304stairplotproblem?requestedDomain=www.mathworks.com 4/4