How to call a variable from a string table and do subsequent operations, then save it as a new variable.
2 ビュー (過去 30 日間)
古いコメントを表示
I have included a picture to ilustrate the situation and added the table file as an attachment.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/789165/image.jpeg)
I would like to call the variable in colum 3 (100 + n),
convert the string to a usable format (int?),
do the addition (100 + n) with a given number n in the editor.
Then call the variable in colum 4, convert it, and do the subtraction x = (number from colum 4) - (given number y)
Finally, multiply the result from (100 + n) with x,
and save that result in a table in workspace asigned to the eqvivalent row variable in colum 1,
and do the same operation for every subsequent row.
Thank you for your answer.
0 件のコメント
回答 (1 件)
Seth Furman
2021 年 11 月 4 日
I would like to convert the string in variable 3 to numeric
Take a look at sscanf.
text = ["100 + n", "115 + n"];
data = zeros(1, length(text));
for i = 1:length(text)
data(i) = sscanf(text(i), "%g + n");
end
data
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!