NaN problem with xlsread

2 vues (au cours des 30 derniers jours)
Utsav
Utsav le 25 Jan 2016
Modifié(e) : Utsav le 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.

Réponse acceptée

Utsav
Utsav le 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.

Plus de réponses (1)

Walter Roberson
Walter Roberson le 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 commentaire
Utsav
Utsav le 25 Jan 2016
Modifié(e) : Utsav le 25 Jan 2016
Thanks Walter for the help...........

Connectez-vous pour commenter.

Catégories

En savoir plus sur Data Distribution Plots dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by