choosing between two array location

my code works when my parced string reads thorugh and places the wanted string in cell 5 but the modify version that i am working on collects two items and places the one i need in cell5 and the unwanted in cell6 and it crashes my script after that.
crashes here due to two cells with data instead of one [] [] [] [] [5] [6] it i may prevent it before getting here from reading string in multiple cells better but after it does fix would be fine as well - im stuck
channel_digits = regexp(channel_data{channel_location}, '\d', 'match');
what may i add so it chooses information in cell5

댓글 수: 5

Jan
Jan 2022년 8월 10일
편집: Jan 2022년 8월 10일
I do not undestand, what you are asking for. You are mentioning "strings", but I do not see a string in the question. Where does " [] [] [] [] [5] [6]" come from?
Please post a relevant part of the code together with some input data and an explanation of the wanted result.
Ihaveaquest
Ihaveaquest 2022년 8월 10일
편집: dpb 2022년 8월 10일
channel_location = strfind(channel_data, channel_identifier); %%% find which parsed location has channel number
channel_location = find(~cellfun(@isempty,parsed_channel_location)); %%%find exact spot
at this point "channel location' is an matrix of 1x6 and it my old code it would return value in one slot but not i am returning values it slot 5 and 6. but i only need value in slot 5 hence, [] [] [] [] [5] [6] need [] [] [] [] [5] []
channel_digits = regexp(channel_data{channel_location}, '\d', 'match'); %%pulls digits out
digits_concatenated = cellfun(@strcat,channel_digits);
matrix_channel_number = str2num(digits_concatenated);
@Ihaveaquest: The problem gets less clear. It is unclear, what your inputs are and what you want to achieve. What is a "slot"? Again: Where does "[] [] [] [] [5] [6]" occur in your code? Just repeating this piece does not clarify anything. Which variable has this value?
Do you want the 5th cell element only, or the first matching variable, or its index?
Post some input data as Matlab code, which run by copy&paste, and explain exactly, what you want as output. I assume, then the solution is simple, e.g.:
match = contains(channel_data, channel_identifier);
channel = channel_data(find(match, 1));
Ihaveaquest
Ihaveaquest 2022년 9월 27일
yes just want the first cell element - sorry i was not very clear i am new to matlab
Rik
Rik 2022년 9월 28일
Please consider using interpunction when writing text. It really helps to understand what you write.
Is your question now solved? Or do you still have a problem?

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

답변 (0개)

카테고리

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

제품

릴리스

R2019a

태그

질문:

2022년 8월 9일

댓글:

Rik
2022년 9월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by