How to define variable names for resampling?

조회 수: 2 (최근 30일)
Devendra
Devendra 2024년 4월 20일
댓글: Devendra 2024년 4월 20일
I am using following code to resample the 10m green,red and nir bands to 20m resolution;
% Resample the 10m bands to 20m
if ismember(files(i + j).name, {'*_B03_10m.jp2', '*_B04_10m.jp2', '*_B08_10m.jp2'})
img = imresize(img, 0.5, 'Method', 'bilinear');
end
But this part of code is being not executed.
The names of band files are as follows
T43RGN_20210119T053141_B03_10m
T43RGN_20210119T053141_B04_10m
T43RGN_20210119T053141_B05_20m
T43RGN_20210119T053141_B06_20m
T43RGN_20210119T053141_B07_20m
T43RGN_20210119T053141_B08_10m
I request you to kindly suggest me how to execute above mentioned part of code also.
Deva

채택된 답변

Stephen23
Stephen23 2024년 4월 20일
편집: Stephen23 2024년 4월 20일
You should:
  • replace the ISMEMBER with ENDSWITH
  • get rid of those asterisks
For example:
endsWith(files(i+j).name, {'_B03_10m.jp2', '_B04_10m.jp2', '_B08_10m.jp2'})
or even simply:
endsWith(files(i+j).name, '_10m.jp2')
You might also like to use the IgnoreCase option.
NOTE: your code does not work because ISMEMBER matches text literally, so what you incorrectly think are wildcard characters that match anything are in fact literal asterisk characters that match... the asterisk character. The ISMEMBER docunentation does not mention wildcard or special characters anywhere: inventing features which do not exist is unlikely to work.
  댓글 수: 6
Walter Roberson
Walter Roberson 2024년 4월 20일
As discussed in https://www.mathworks.com/matlabcentral/answers/2109356-how-to-use-enviwrite-in-matlab enviwrite() expects a hypercube object. A version of enviwrite() that expects a cuboid of data is at https://github.com/akayasse/ENVI-read-and-write-for-MATLAB
Devendra
Devendra 2024년 4월 20일
Thanks for your help. I have written envi file using enviwrite function. However, map information (latitude and longitude) with projection are missing. Please suggest me how to incorporate map information into envi header file. I will appreciate your kind help.
Devendra

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with GPU Coder에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by