write a xlsx file

1 Ansicht (letzte 30 Tage)
assia assia
assia assia am 21 Jul. 2021
Kommentiert: Walter Roberson am 21 Jul. 2021
Hello folks,
I have a mat file structed as follow and I would like to convert it to xls format.
k = load('psnr_ssim_Stokes_Double_Difference.mat')
k =
struct with fields:
psnr_value_I: [7-D double]
psnr_value_Q: [7-D double]
psnr_value_U: [7-D double]
ssim_value_I: [7-D double]
ssim_value_Q: [7-D double]
ssim_value_U: [7-D double]
I used this code but it didn't give me the content of the variables in a columns I got them in row. This is the code that I used
filename = 'psnr_ssim.xlsx'
T = table(ssim_value_I,psnr_value_I,ssim_value_Q,psnr_value_Q,ssim_value_U,psnr_value_U)
writetable(T,filename)
  12 Kommentare
assia assia
assia assia am 21 Jul. 2021
Bearbeitet: assia assia am 21 Jul. 2021
data = load("data.mat")
k = struct2table(data)
writetable(k,'data.csv')
Walter Roberson
Walter Roberson am 21 Jul. 2021
Is "data.mat" the same file as in
save('psnr_ssim_Stokes_Linear_Seperable.mat','ssim_value_I','psnr_value_I','ssim_value_Q','psnr_value_Q','ssim_value_U','psnr_value_U')
? If so then 'ssim_value_I' is length(g_vals) by 6 other dimensions, and you have two different g_vals, so ssim_value_I would be 2 x 6 other dimensions. When you do the struct2table() the 2 x something becomes a table with two rows.
You can convert to individual variables by using splitvars(); see https://www.mathworks.com/help/matlab/ref/table.splitvars.html
... but keep in mind that you will then have a table with a lot of different columns, each of which is only 2 rows long.
I would suggest to you that you should be considering permute() and then reshape() to get the data in the order you want.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Tables finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by