Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Addition of data from different files using a loop

조회 수: 1 (최근 30일)
Joydeb Saha
Joydeb Saha 2020년 5월 19일
마감: MATLAB Answer Bot 2021년 8월 20일
clear
clc
[files,pathname]=uigetfile('*.hdf','MultiSelect','on');
cd ../../../../../../../../../..
cd(pathname)
files=files';
NumFiles=length(files);
%FMF_S=zeros(31,1);
for m=1:NumFiles
filename=files(m);
filename=char(filename);
data=hdfread(filename,'Ice_Water_Content_Profile'); %reading ice water dataset
lat=hdfread(filename,'Latitude');
lat=double(squeeze(lat(:,1)));
data(data==-9999)=nan; %removing fill value
data(data<0 | data>0.54)=nan; %removing out of range values
% data(data==0)=nan;
data(m,:)=data;
end
say i have three files, a.hdf anf b.hdf and c.hdf, i want the data should be added up in each case , and data matrix dimention remains the same. say for the first file data=846x399 double, when all the three files added up, matrix will remain the samr, i.e, 846x399 double but the three files data shall added up. how to do it with loop? I am getting "Subscripted assignment dimension mismatch." when i use my code,
  댓글 수: 1
Sindar
Sindar 2020년 5월 19일
data(m,:)=data;
takes all of data, and puts it into the first row of data. So, you're trying to fit an 846x399 matrix in a 1x399 column.

답변 (0개)

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by