Note that there are some explanatory texts on larger screens.

plurals
  1. POusing datenum results in not showing both strings
    primarykey
    data
    text
    <p><strong>1. How do I read in this data properly so that the date parses properly?</strong> I am trying to concatenate strings I read from a file but the output I get is mixed up. The output is the x axis.Also, the spacing from x axis has numbers instead of the string I want. The file has 4 columns,date,time,temperature and value. The date is "01.01.2013 " and the time "09:08:02"</p> <p>Also, if I want to use only first column (with date) how can I do this? Because using datenum(mydata{1}) results to "Cannot parse date 01.01.2013"</p> <pre><code>... mydata = textscan(fid, '%s %s %f %f', 'delimiter',';', 'HeaderLines',1); date={}; temp={}; .. date{1}=datenum( strcat(mydata{1},{' '},mydata{2}) ); ... </code></pre> <p><strong>2. How do I correct the axis ticks?</strong> </p> <p>I am then trying to plot data using plotyy and want the x-axis to be the date, but I am getting two different axis labels.</p> <p>Here is the code I am using:</p> <pre><code>temp = mydata{4}; plotyy(date,temp,date,2*temp); datetick('x','mmm.dd,yyyy'); </code></pre> <p>Here is the resulting image:</p> <p><img src="https://i.stack.imgur.com/tpYGR.png" alt="enter image description here"></p> <p>---------------UPDATE---------------------------------------</p> <p>Here is the code:</p> <pre><code>fid = fopen('test2.txt','r'); mydata = textscan(fid, '%s %s %f %f', 'delimiter',';', 'HeaderLines',1); fclose(fid); date=datenum( strcat(mydata{1},{' '},mydata{2}),'mmm.dd,yyyy HH:MM:SS' ); temperature=mydata{3}; value=mydata{4}; [AX,H1,H2]=plotyy(date,temperature,date,value,'plot'); set(get(AX(1),'Ylabel'),'String','Temperatures'); set(get(AX(2),'Ylabel'),'String','Value'); set(H1,'LineStyle','--'); set(H2,'LineStyle',':'); datetick(AX(1),'x','mmm.dd,yyyy'); title('Temperatures - Values'); xlabel('Date') </code></pre> <p>and the file</p> <pre><code>Date;Time;Temp;value Jan.01,2013; 11:00:00;20;10 Feb.08,2013; 12:00:00;23;11 Mar.04,2013; 04:02:00;24;15 Apr.10,2013; 08:04:00;28;20 May.10,2013; 12:05:00;32;30 Jun.04,2013; 10:06:0;33;27 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload