NaN problem with xlsread

2 次查看(过去 30 天)
Utsav
Utsav 2016-1-25
编辑: Utsav 2016-1-25
My code :
[Day, txt_day, raw_day] = xlsread('file.xlsx',1,'A:A');
[Paramet, txt1, raw1] = xlsread('file.xlsx',1,'F:F');
file.xlsx has Day in A column, Paramet in F.
For some day in A, some entries in F in NaN.........
I wish to plot(A,Paramet), but Paramet has lesser rows than Day, as NaN's in F are not recognized by xlsread.
I wish to plot all Day of A column, and NaN as blanka at appropriate X values
Any help.

采纳的回答

Utsav
Utsav 2016-1-25
Idea is to find character assign NaN and replace NaN values to Matrix
ival = cellfun(@ischar,raw1);
raw1(ival) = {NaN};
Paramet_1 = cell2mat(raw1);
Paramet_2=Paramet_1(2:(numel(Day)+1),:);
Paramet_2 contains my required datasets
Thanks Laura.Thanks Mathworks.

更多回答(1 个)

Walter Roberson
Walter Roberson 2016-1-25
all_day = cell2mat(raw_day);
num_day = length(all_day);
all_Paramet = cell2mat(raw1);
num_Paramet = length(all_Paramet);
if num_Paramet < num_day
all_Paramet(end+1:num_day) = NaN;
elseif num_day < num_Paramet
all_day(end+1:num_Paramet) = NaN;
end
plot(all_day, all_Paramet)
  1 个评论
Utsav
Utsav 2016-1-25
编辑:Utsav 2016-1-25
Thanks Walter for the help...........

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Data Distribution Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by