Borrar filtros
Borrar filtros

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 visualización (últimos 30 días)
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?

Respuestas (1)

Walter Roberson
Walter Roberson el 20 de Mzo. de 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 comentario
javad amoli
javad amoli el 21 de Mzo. de 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

Iniciar sesión para comentar.

Categorías

Más información sobre Timing and presenting 2D and 3D stimuli en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by