Warning: Attempt to write an unsupported data type to an ASCII file. I am trying to save a matrix to an ascii file but it keep throwing this error
23 views (last 30 days)
Show older comments
I am writing a code for a homework assignment that does a variety of things. One of the thing it has to do is load antennaData.mat and manipulate the theta and rho vector and then concatenate them into a matrix. Then, I have to save the matrix to an ascii file. All is well and good but when I try to save the matrix I get the error "Warning: Attempt to write an unsupported data type to an ASCII file"
This is the sample of my code that throws the error. I looked at other question regarding similar issues but those errors were the resulkts of matrices not using numberic elements. But my matrix has numeric values as it should. So I'm very lost as to why its throwing an error.
load antennaData.mat
theta = [theta(1:end); 2*pi + theta(2:end)];
rho = [rho(1:end); 2*pi + rho(2:end)];
M = [theta, rho];
save 'M' '-ASCII';
2 Comments
Accepted Answer
Cris LaPierre
on 9 Oct 2021
save M.txt M -ascii
% or
save('M.txt', 'M', '-ascii')
3 Comments
Cris LaPierre
on 9 Oct 2021
You need to be aware of the proper syntax in order to get the result you expect. Use the doc for that. Here is a list of valid syntaxes for save
- save(filename)
- save(filename,variables)
- save(filename,variables,fmt)
- save(filename,variables,version)
- save(filename,variables,version,'-nocompression')
- save(filename,variables,'-append')
- save(filename,variables,'-append','-nocompression')
- save filename
With only 2 inputs, I suspect it was trying to treat '-ascii' as your variable
More Answers (0)
See Also
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!