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

1 回表示 (過去 30 日間)
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?

回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 3 月 20 日
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 件のコメント
javad amoli
javad amoli 2018 年 3 月 21 日
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

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by