Removing quotation marks in a string using for loop

3 ビュー (過去 30 日間)
Chris Dan
Chris Dan 2022 年 7 月 7 日
コメント済み: Les Beckham 2022 年 7 月 7 日
Hi,
I have a short question, I am creating a string with a loop but I cannot remove the quotation marks " ".
here is my code
folder_name_dia = linspace(0.05,5,100); % used to create an automatic string
for p=1:length(folder_name_dia)
test{p} = "diam_" +folder_name_dia(p);
end
test = test';
Does any know how can i remove the quotation marrks " "

採用された回答

Les Beckham
Les Beckham 2022 年 7 月 7 日
編集済み: Les Beckham 2022 年 7 月 7 日
The quotation marks are not actually part of the string. It is just displayed that way. Plus, since you are using strings instead of character vectors, you don't need to put them in a cell array. You can use a string array (with regular parentheses instead of curly braces):
folder_name_dia = linspace(0.05,5,100); % used to create an automatic string
for p = 1:length(folder_name_dia)
test(p) = "diam_" + folder_name_dia(p);
end
test = test';
test(1) % this shows the quotation marks to give you an indication that this is a string
ans = "diam_0.05"
disp(test(1)) % this just shows the string itself which doesn't actually have any quotation marks
diam_0.05
  2 件のコメント
Chris Dan
Chris Dan 2022 年 7 月 7 日
I understood :-) Thank you so much
Les Beckham
Les Beckham 2022 年 7 月 7 日
You are quite welcome.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by