matlab read only first letter from string

3 ビュー (過去 30 日間)
void22
void22 2018 年 6 月 21 日
回答済み: void22 2018 年 6 月 21 日
hello i wrote the following code to create a list of strings related to files that i have :
formatspec = 'f%dK.csv';
for i =0:16
myfiles(i+1,:)= sprintf(formatspec,i);
end
but now that i check the string , for example i write in the command window myfiles(1) and matlab prints 'f' when i click myfiles in the workspace it shows me the full string that i coded 'f0K.csv' what is causing this? thanks!

採用された回答

void22
void22 2018 年 6 月 21 日
actually it wasn't the problem but i figured it out , for others : the variable called myfiles is a vector of strings , but when i call a specific string i must use my files(3,:) so it calls the entire string and not only the first letter .

その他の回答 (1 件)

Majid Farzaneh
Majid Farzaneh 2018 年 6 月 21 日
Hi, You should use a function to read your data like:
M = csvread(filename)
In your code
formatspec = 'f%dK.csv';
is a string. It does not read your file. You assigned 'f0K.csv' (a string value) to formatspec.

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by