How to find values in structure?

Hi, I loaded some .tif files into Matlab like this:
D = 'my path';
S = dir(fullfile(D,'*.tif'))
for k = 1:numel(S);
F = fullfile(D,S(k).name);
S(k).data = imread(F);
end
And I'm trying to get selected values from these .tif files. When I had only one file loaded (as a single array, not into structure), I could do this:
Regions=imread('RegionsFile.tif');
FirstParameterDate=imread('FirstParameterDate.tif');
SecondParameterDate=imread('SecondParameterDate.tif');
x=find(Regions==5);
MyRegionFirstParameter=FirstParameterDate(x);
MyRegionSecondParameter=SecondParameterDate(x);
Answer=find(MyRegionFirstParameter>=2&MyRegionSecondParameter<5);
But I don't know how to find values in .tif files loaded into structure like this?
This:
x=find(Regions==5);
MyRegionFirstParameter(:).data=find(S(:).data==x);
or
MyRegionFirstParameter(1).data=S(1(x)).data;
is not working.

 Accepted Answer

Like this
MyRegionFirstParameter(1).data(x) = S(1).data(x);

2 Comments

Thank you, it works.
I am glad to be of help!

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!