NaN problem with xlsread

2 views (last 30 days)
Utsav
Utsav on 25 Jan 2016
Edited: Utsav on 25 Jan 2016
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.

Accepted Answer

Utsav
Utsav on 25 Jan 2016
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.

More Answers (1)

Walter Roberson
Walter Roberson on 25 Jan 2016
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 Comment
Utsav
Utsav on 25 Jan 2016
Edited: Utsav on 25 Jan 2016
Thanks Walter for the help...........

Sign in to comment.

Categories

Find more on Data Distribution Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!