How to write output data in excel csv files?

조회 수: 1 (최근 30일)
Devendra
Devendra 2024년 3월 25일
편집: gauri 2024년 5월 19일
My for loops are as follows;
number of image files are 114
number of shape files are 242
for m = 1:length(imgfiles)
for n = 1:length(shapefiles)
avg_village_ndvi(n,m) = mean(village_ndvi(mask));
avge_village_ndre1(n,m) = mean(village_ndre1(mask));
avg_village_cire(n,m) = mean(village_cire(mask));
CAF(n,m) = nnz(village_ndvi(mask) > 0.4) / (size(village_ndvi,1)*size(village_ndvi,2))
end
end
I want to write these data in seperate excel csv file with file name as 'c:\data\ndvi_predictors.csv','c:\data\ndre1_predictors.csv','c:\data\cire_predictors.csv' and 'c:\data\caf_predictors.csv'.
I request all to please suggest me how to do it in above mentioned matlab code.
I would appreciate any help in this regard.
Dave

채택된 답변

Voss
Voss 2024년 3월 25일
After the for loops:
writematrix(avg_village_ndvi,'c:\data\ndvi_predictors.csv')
writematrix(avge_village_ndre1,'c:\data\ndre1_predictors.csv')
writematrix(avg_village_cire,'c:\data\cire_predictors.csv')
writematrix(CAF,'c:\data\caf_predictors.csv')
  댓글 수: 23
Voss
Voss 2024년 5월 7일
You're welcome!
gauri
gauri 2024년 5월 19일
편집: gauri 2024년 5월 19일
Once again I seek your kind help to retrieve the data using shape file. I am using the mask to extract the data using shape file as follows;
mask = reshape(isinterior(polygon, lon(:), lat(:)), [length(lat), length(lon)]);
% Convert the logical mask to uint16 format
maskConverted = uint16(mask);
% Apply the converted mask to the raster
imgMasked = img .* maskConverted;
The size of imgMasked is same as that of img(5490 5490 7). However, it contains non zero data over shape file area and zeros over rest of the image data. I wanted to retrieve the non zeros data from imgMasked as per the size of the shape file. I request you to please suggest me how to retrieve the desired data from imgMasked. I have kept the imgMasked.mat file on following google link;
I request you to please have a look on it and suggest me how to get required data from imgMasked.
I would be highly obliged to you.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by