How to Convert .mat to xml?

64 ビュー (過去 30 日間)
Disha
Disha 2023 年 2 月 4 日
回答済み: Jasvin 2023 年 2 月 10 日
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
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
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

カテゴリ

Help Center および File ExchangeStructured Data and XML Documents についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by