Have a .mat file in the Work space and i need to view the image in it

1 回表示 (過去 30 日間)
Pankaja Tanjore
Pankaja Tanjore 2015 年 6 月 15 日
コメント済み: Pankaja Tanjore 2015 年 6 月 16 日
Hello , I have .mat file in the Work space which contains the Image data. I need to view the image in it. Let me know how this is done. I need to extract the image and display this image in MATLAB GUI.
Looking forward to hear from you at the earliest.
Thanks Pankaja

採用された回答

Walter Roberson
Walter Roberson 2015 年 6 月 15 日
.mat files always contain named variables, not just pure data. There may be several variables in one .mat. We do not know which variable to load (you did not specify), so we will assume that the first variable in the list is the one to load. If there is only one variable then it would be the first.
datastruct = load('TheFileNameHere.mat');
varnames = fieldnames(datastruct);
var_to_load = varnames{1};
imagedata = datastruct.(var_to_load); %pull out the data for that variable
imagesc(imagedata); %view it
  1 件のコメント
Pankaja Tanjore
Pankaja Tanjore 2015 年 6 月 16 日
Thanks for the reply walter. It was very helpful

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by