Removing nan values inside cells of a cell array and keeping the og structure
Mostra commenti meno recenti
Hi,
I have looked into
and
However, as for my problem. I have a [1Xn] cell, where within it one of these is a [kXv] cell. It is easy to extract each of the cells in the cell array and remove all NAN, but I want to keep the origninal structure. Therefore I am asking if it is possible to have a simple line of code that doesent split up all of the cells in the cell array so I dont have to paste them toegether at a later stage?
2 Commenti
Ameer Hamza
il 2 Dic 2020
The solution depends on how you data is structured? Can you share your cell array?
Risposte (1)
Image Analyst
il 7 Dic 2020
Why would extracting those and removing nans change the original structure of the cell array? Why can't you just do this:
for k = 1 : numel(raw)
ca = raw{k}; % Get k'th cell of the raw cell array.
[rows, columns] = size(ca);
% ca is a cell array of character strings.
for col = 1 : columns
for row = 1 : rows
contents = ca{row, col};
% You cannot remove a cell from a cell array
% but you can set it's contents to null instead of NaN.
if isnan(contents)
contents = [];
end
end
end
end
4 Commenti
Saud Alfalasi
il 7 Dic 2020
Hi IA.
Please may you look at this question:
https://www.mathworks.com/matlabcentral/answers/668383-recombine-cell-arrays-to-produce-a-new-image?s_tid=mlc_ans_email_ques
Image Analyst
il 8 Dic 2020
Yes. Since you forgot to include your variable, I had to do it without testing. I forgot that you have to stick contents back into ca, and then ca back into raw
ca{row, col} = contents; % Put repaired contents back into the cell.
raw{k} = ca; % Put the cell ca back into the cell array raw.
Attach your raw if you need more help.
save('answers.mat', 'raw');
Then use the paperclip icon to attach answers.mat.
Erik From
il 9 Dic 2020
Categorie
Scopri di più su Matrices and Arrays in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



