Hi, I've got a variable that gives me all the messages that have the value I asked for.
What I want is to get a variable that gives me the position where I can find the number 215382000 the final output would be:
first cell = 5
second cell = 6
third cell = 10
fourth cell = 11
like this. Here I upload the data too

 채택된 답변

Jon
Jon 2021년 10월 26일

0 개 추천

Assuming you just want the non-empty cells
idx = find(~cellfun(@isempty,Msg_mmsi_selected))

댓글 수: 2

Jon
Jon 2021년 10월 27일
I noticed you accepted Cris' answer. His answer works, but I think the approach I have here does the same thing in just one line. That would seem preferable. I'm wondering if there is something that I missed.
flashpode
flashpode 2021년 10월 27일
Both make the same, it was ust the first one I saw. Yours is better just 2 variables less

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

추가 답변 (1개)

Cris LaPierre
Cris LaPierre 2021년 10월 26일

0 개 추천

Not sure of a single function solution, but this works.
load msg_mmsi_selected
ind = ~cellfun("isempty",Msg_mmsi_selected);
V = 1:length(Msg_mmsi_selected);
c = V(ind)
c = 1×61456
5 6 10 11 13 15 21 32 44 48 54 55 66 67 73 74 77 80 87 89 92 96 100 104 112 121 128 131 132 133

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

태그

질문:

2021년 10월 26일

댓글:

2021년 10월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by