How can I assign a variable to a string?
古いコメントを表示
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 件のコメント
Image Analyst
2020 年 6 月 14 日
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
2020 年 6 月 14 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!