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!