Reputation: 1176
I am new to matlab, though i have done a fair amount of programming in R and java. I am trying to save a file using the save function in matlab. The name of the file I want to save to should contain a string read from a .txt file.
sp500=textread('C:\\Users\\Paul\\Downloads\\algo\\sp500.txt','%s');
save(sp500{i},cleanedVolume)
But when I try this, I get the error: Argument must contain a string.
If I understand correctly, sp500 is a cell array of character arrays. So perhaps the reason why matlab doesn't like this is that I am trying to use a char array instead of a string. I have looked everywhere on the internet, and nowhere does it say how to convert a character array to a string in matlab. Or alternatively, if anyone could explain how to read this text file into cell array of string instead, that would probably be good enough for me to get it to work. but if someone could please explain what is going on here, i.e. why the readtxt returns character cells even though I specified the string format, why there is no built in function for reading string from a file and why you can't easily convert from a character array to a string, that would be great.
Could someone please help me with this? thanks, Paul
Upvotes: 0
Views: 72