I want to know how to create a struct type mat file

2 次查看(过去 30 天)
how to create a struct type mat file with different fields .for example in this way .can anyone please help me create a mat file in this way ,thank you in advance.
  1 个评论
Bob Thompson
Bob Thompson 2021-5-4
I'm not sure I understand what you mean by a 'struct type mat file'. A mat file stores matlab workspace entities, which can include structure variables. Is that an acceptable solution?

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2021-5-4
result = cell2struct({currency.feature}, {currency.name}, 2);
The result would be a struct with fields named 'Dollar', 'pound', 'rupee', 'yen', with value according to the feature value.
  1 个评论
Sowgandhi Pasupuleti
I am having 24 images in currency folder .I am getting error while I am using cell2struct in my code .Can yoy please suggest we how to use in my code.Thank you in advance
MyFolder = 'M:\matlab programs\currency';
FilePattern = fullfile(MyFolder, '*.jpg');
TheFiles = dir(FilePattern);
for k = 1 : length(TheFiles)
BasefileName = TheFiles(k).name;
FullFileName = fullfile(MyFolder, BasefileName);
im=imread(FullFileName);
%preprocessing
%resize image
im=imresize(im,[128 128]);
%remove noise;
%seperate channels
r_channel=im(:,:,1);
b_channel=im(:,:,2);
g_channel=im(:,:,3);
%denoise each channel
r_channel=medfilt2(r_channel);
g_channel=medfilt2(g_channel);
b_channel=medfilt2(b_channel);
%resltore channels
rgbim(:,:,1)=r_channel;
rgbim(:,:,2)=g_channel;
rgbim(:,:,3)=b_channel;
%featureextraction
[fet1,fet2,fet3]=totalfeature(rgbim);% calls the function totalfeature
fet(:,k)=[fet1;fet2;fet3]; % fet has the 78 features of each image
end
save('fet.mat');
%Total feature code:
function [fet1,fet2,fet3]=totalfeature(rgbim)
%color feature
fet1=color_luv(rgbim);
%edge feature
fet2=edgehist(rgbim);
%texture feature
%glcm-gray level co occurrence matrix
glcm=graycomatrix(rgb2gray(rgbim));
fet3=glcm(:);

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by