I want to plot my outputs , X vector is text format ( for example 10/3/2015-8:00-8:15 ) and my Y vector is number . how should i plot them ? I got error on text format

5 visualizzazioni (ultimi 30 giorni)
I got error on text format , seem that both of the vector must be number .
another Q : how can I change the shape of the graph?

Risposte (1)

Walter Roberson
Walter Roberson il 20 Mar 2018
You need to convert those time strings to datenum or datetime objects, as we discussed with you in https://www.mathworks.com/matlabcentral/answers/382006-what-is-this-eror-and-what-does-it-mean-and-how-can-i-solve-it#answer_304563
  1 Commento
javad amoli
javad amoli il 21 Mar 2018
I know it, I did my changes on it, I don't know why it doesn't work . look at my code and my CSV file plz.
function [Time_stamp, Original_load_kw]=Plot()
filename = 'Dterministic_Output_data.csv';
delimiter = ',';
startRow = 2;
formatSpec = '%{yyyy-mm-ddTHHMMSS}D%*s%[^\n\r]';
fileID = fopen(filename,'r');
dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'HeaderLines' ,startRow-2);
%dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'TextType', 'string', 'EmptyValue', NaN, 'HeaderLines' ,startRow-1, 'ReturnOnError', false, 'EndOfLine', '\r\n');
a = datestr(dataArray{1,1},'yyyy-mm-ddTHHMMSS');
Time_stamp = cellstr(a);
fclose(fileID);
formatSpec = '%*s%f%[^\n\r]';
fileID = fopen(filename,'r');
dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'HeaderLines' ,startRow-2);
%dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'TextType', 'string', 'EmptyValue', NaN, 'HeaderLines' ,startRow-1, 'ReturnOnError', false, 'EndOfLine', '\r\n');
Original_load_kw = dataArray{:, 1};
fclose(fileID);
X = datenum( Time_stamp,'yyyy-mm-ddTHHMMSS');
stem( X, Original_load_kw );
datetick('x','yyyy-mm-ddTHHMMSS'),
end

Accedi per commentare.

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by