MATLAB: How to find values in structure

findimagesloadingstructure

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.

Best Answer

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