Hello,
I have a 4x20 cell array where each cell in the array is a 40x1 column vector. The data in this cell array is from Excel. I am trying to remove all of the '1x1 missing' entries in this cell array (i.e. from each of these column vector cells). I tried this but it doesn't work:
new_cell_array{1}= cellfun(@rmmissing,old_cell_array{1},'UniformOutput',false)
new_cell_array ends up being a 40x1 cell. I want new_cell_array to be a 4x20 cell array that is basically just old_cell_array but with the 'missing' entries removed. Any suggestions would be much appreciated
Thank you

 채택된 답변

Jon
Jon 2022년 7월 7일

0 개 추천

I think you are close, just use
new_cell_array= cellfun(@rmmissing,old_cell_array,'UniformOutput',false)

댓글 수: 4

Davindra Usov
Davindra Usov 2022년 7월 7일
Hi,
Thank you for your reply. When I do this, I get this error:
Error using matlab.internal.math.ismissingKernel/arraySwitch (line 79)
First argument must be numeric, logical, datetime, duration, calendarDuration, string,
categorical, char, cellstr, table, or timetable.
Jon
Jon 2022년 7월 7일
Please save your variable old_cell_array as a .mat file and attach it using the paperclip so I can see what you are actually applying the cellfun to.
Davindra Usov
Davindra Usov 2022년 7월 7일
Unfortunately I can't send the data itself cause it's confidential :( But it's basically a 4x20 cell array and each cell within that array is a 40x1 column vector which contains some numbers and some '1x1 missing' entries which I'm trying to remove. I read in the data from Excel
Jon
Jon 2022년 7월 7일
The above works fine for the example I constructed, so your error must have to do either with exactly how you wrote the code, maybe even a typo, or something about the exact contents/types etc in your matrix. Without having access to either of those I can't really help you further. I understand that the data is confidential, but if you could just attach an example cell array that demonstrates the problem, but has random values (non-confidential) and attach a small, generic (non-confidential) piece of code that reproduces the problem I might be able to help.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

제품

릴리스

R2021b

태그

질문:

2022년 7월 7일

댓글:

Jon
2022년 7월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by