Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Pairing two different values on one plot
Replies: 19   Last Post: Apr 18, 2013 2:44 AM

 Messages: [ Previous | Next ]
 dpb Posts: 9,850 Registered: 6/7/07
Re: Pairing two different values on one plot
Posted: Apr 15, 2013 9:52 AM

On 4/15/2013 1:09 AM, PK wrote:
...

> Timestamp=
> 201203291200000
> 201203291215000

...
> 201203291415000
> and
> Data =
> 5

...
> 80
>
> length of both A and B is same say 700. Basically first value of
> Timestamp corresponds to first value of Data.
> Now I want to plot Timestamp on x-axis and Data on y-axis so that I can
> find the value of data at particular time.
>
> I have used
> plot (Data, Timestamp);
> but the output is awefuly different than ploting Data itself.

As others said, that's bass-ackwards--it's

plot(Timestamp,Data) to put time on x-axis.

To effectively plot time on x-axis,

a) convert the timestamp data to datenums via datenum...

>> ts=strvcat(num2str(TS,'%14d'));
>> dn=datenum(ts(:,1:12),'YYYYmmddHHMM');
>> datestr(dn)

ans =
29-Mar-2012 12:00:00
29-Mar-2012 12:15:00
29-Mar-2012 14:15:00
>>

plot(dn,data)

c) use datetick to display axis in time..

datetick('x','keeptick')

doc datenum % and friends
doc datetick

--

Date Subject Author
4/15/13 PK
4/15/13 Nasser Abbasi
4/15/13 PK
4/15/13 Nasser Abbasi
4/15/13 Lothar Schmidt
4/15/13 dpb
4/15/13 PK
4/16/13 Derek Goring
4/16/13 PK
4/16/13 PK
4/16/13 dpb
4/16/13 Steven Lord
4/16/13 dpb
4/16/13 PK
4/16/13 dpb
4/17/13 PK
4/17/13 dpb
4/18/13 PK
4/15/13 dpb
4/15/13 dpb