2
votes

I'd like some help with my Matlab problem. I'm working on macOS with Matlab R2016b. I want to convert a .mat file containing a matrix of 1088 rows and 832 columns into a .txt file.

I tried the above code without success.

load('H.mat')
dlmwrite('H.txt')

By loading the matrix on matlab I find the following informations :

a

Thank you.

1
You need to specify the matrix to be written onto the file: dlmwrite('H.txt', H)Luis Mendo
Thanks Lui mendo, I've tried your code but I'm finding this error : Undefined function 'real' for input arguments of type 'struct'. Error in dlmwrite (line 189) str = sprintf('%.*g%+.*gi',precn,real(m(i,j)),precn,imag(m(i,j)));m2016b
Sorry, I didn't realize H is a field of a struct variable called code. Try dlmwrite('H.txt', code.H)Luis Mendo

1 Answers

2
votes

dlmwrite is not recommended by matlab: Better use

load('H.mat')
writematrix(H, 'H.txt') 

see writematrix documentation.