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 comentarios

Jan
Jan el 10 de Ag. de 2022
Editada: Jan el 10 de Ag. de 2022
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 el 10 de Ag. de 2022
Editada: dpb el 10 de Ag. de 2022
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 el 27 de Sept. de 2022
yes just want the first cell element - sorry i was not very clear i am new to matlab
Rik
Rik el 28 de Sept. de 2022
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?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Productos

Versión

R2019a

Etiquetas

Preguntada:

el 9 de Ag. de 2022

Comentada:

Rik
el 28 de Sept. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by