How can I assign a variable to a string?
Mostra commenti meno recenti
I have a mat file containing a table one column with numbers from 1 to 50, I just want to assign avariable to first column an than apply this:
tf = ismember(M, [7; 8; 9]);
idx = find(diff(tf)>0)+1+(0:12);
answer = reshape(M(idx).', [], 1)
If I put
M = [1 2 3 4...49 50]
and then
tf = ismember(M, [7; 8; 9]);
idx = find(diff(tf)>0)+1+(0:12);
answer = reshape(M(idx).', [], 1)
I have the correct results that display only the numbers after 9 but I want to exclude the M = [1 2 3 4...49 50] and to assign a variable to entire column because my numbers are always different except 7,8,9
I tried this
M = T(:,:);
where T is the table from mat file but:
Error using table/ismember (line 27)
A and B must both be tables.
If I put directly:
tf = ismember(X, [7; 8; 9]); %X is table from mat file
idx = find(diff(tf)>0)+1+(0:12);
vals = reshape(X(idx).', [], 1);
I get this error :
Error using +
Matrix dimensions must agree.
Thanks
2 Commenti
Image Analyst
il 14 Giu 2020
You forgot to format your code and attach your mat file. I formatted it for you but I can't attach your mat file for you.
Cristian Martin
il 14 Giu 2020
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Data Type Conversion 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!