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

2 views (last 30 days)
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 Comment
Bob Thompson
Bob Thompson on 4 May 2021
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?

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 4 May 2021
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 Comment
Sowgandhi Pasupuleti
Sowgandhi Pasupuleti on 6 May 2021
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(:);

Sign in to comment.

Categories

Find more on Structures in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!