Help with the code for converting hyperspectral image to excel file
이전 댓글 표시
please check and let me know how to run this code on matlab. I already used hypertools for clustering and now need help with the code given below.
cellsample=who('prep_sample');
cellmask=who('prep_mask');
cellsizeofsample= size(cellsample);
width = cellsizeofsample(1,1);
column=cellsizeofsample(1,2);
cellmaskedsampleimage = cell(width,column);
for i=1:width
mask=eval(cellmask{i,1});
sample=eval(cellsample{i,1});
cellmaskedsampleimage{i,1} = maskedimg(mask,sample);
end
clear mask sample 1
cellarrayconerted2matrix= cell(width,column);
for i=1:width
sample=cellmaskedsampleimage(i,1);
band=size(sample);
band=band(i,3);
cellarrayconerted2matrix(i,1)=reshape(sample,[],band);
end
clear sample Band 1
cellfinaldata = cell(width,column);
for i = 1:width
data = cellarrayconvertedtomatrix(i,1);
data( ~any(data,2), : ) = [];
cellfinaldata(i,1)=data;
end
clear data 1
mkdir Output;
dataSaveDir = 'Output'
dataname = 'Soybean_'
datasetname='X';
fileextension = '_txt.';
for i=1:width
filename=[dataSaveDir,dataname, datasetname,num2str(i),fileextension];
writematrix(cellfinaldata(i,1), filename);
end
for i=1:width
filename=[dataSaveDir, dataname,datasetname,num2str(i),'.csv'];
writematrix(cellfinaldata(i,1), filename);
end
clear filename : column width cellsizeofsample
MatfileName = ('workspace');
filename= [dataSaveDir, dataname, datasetname, MatfileName, 'mat'];
save(filename);
clear dataSaveDir dataname datasetname fileextension Matfilename filename
답변 (1개)
Image Analyst
2022년 6월 24일
Try this:
baseFileName = sprintf('%s%s%d.xlsx', dataname, datasetname, i);
fullFileName = fullfile(dataSaveDir, baseFileName);
writematrix(cellfinaldata(i,1), fullFileName);
댓글 수: 8
Amanda Malik
2022년 6월 24일
Image Analyst
2022년 6월 24일
Amanda, if you don't have the maskedimg function then I certainly don't. Why did you write that into your code if you don't have that function?
Amanda Malik
2022년 6월 24일
Amanda Malik
2022년 6월 24일
Image Analyst
2022년 6월 24일
Sorry, no.
Walter Roberson
2022년 6월 24일
Which MATLAB release are you using?
Amanda Malik
2022년 6월 24일
Walter Roberson
2022년 6월 24일
You have two calls
writematrix(cellfinaldata(i,1), filename);
Change each of those to
writematrix(cellfinaldata{i,1}, filename);
카테고리
도움말 센터 및 File Exchange에서 Process Point Clouds에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!