How to Convert .mat to xml?
19 次查看(过去 30 天)
显示 更早的评论
I have a .mat file, and I tried to use the foolowing to convert it to a .xml file.
>> [fname1,fpath1] = uigetfile('*.mat');
if fpath1==0, error('no file selected'); end
[num,txt,raw] = read( fullfile(fpath1,fname1) );
The error message is as follows
Incorrect number or types of inputs or outputs for function 'read'.
I know the problem is using the read function for .mat. Can anyone tell me what to use so that I can save the file further on in xml using the save function?
Thank you.
1 个评论
Rik
2023-2-4
Why do you want to use the save function to write xml files, and why aren't you using load to read your mat file?
回答(1 个)
Jasvin
2023-2-10
The read() function has several uses which include reading data from a datastore (https://www.mathworks.com/help/matlab/ref/matlab.io.datastore.read.html?s_tid=doc_ta) but it’s not used to read .mat files. For that you can use the load() function directly as:
load(fullfile(fpath1, fname1));
For more information regarding the load function refer to the below link:
This will get the variables you want in the base workspace. But to convert the .mat file to XML you can directly use the mat2xml function of the XML4MAT module on FileExchange. You can refer to the link below: https://www.mathworks.com/matlabcentral/fileexchange/6268-xml4mat-v2-0?s_tid=srchtitle_convert%2520mat%2520to%2520xml_2
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Standard File Formats 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!