필터 지우기
필터 지우기

How can I convert every cell of cell array into individual arrays?

조회 수: 1 (최근 30일)
Sevil Cansu Yildirim
Sevil Cansu Yildirim 2020년 1월 31일
편집: Sevil Cansu Yildirim 2020년 1월 31일
Hello, I have a 5 x 13 cell array and I have to calculate some values (gaussian probability density function and logaritmic distribution pdf) for every cell of it. Here is my code;
for i = 1:nlat
for j = 1:nlon
CELL = cell2mat(DIST([i,j])); % HERE I TRIED TO TREAT EVERY SINGLE CELL AS AN INDIVIDUAL ARRAY
PDF(i,j) = (1./(SDIST(i,j)*2*pi))*exp(-0.5*((CELL(i,j)-MDIST(i,j))./SDIST(i,j)).^2); % CALCULATING GAUSSIAN PDF
LD(i,j) = exp(MDIST(i,j)+0.5*(SDIST(i,j).^2)); % CALCULATING LOGARITMIC PDF
end
end
But I end up with this error mesage;
Index in position 2 exceeds array bounds (must not exceed 1).
Error in all_velocities4 (line 50)
PDF(i,j) = (1./(SDIST(i,j)*2*pi))*exp(-0.5*((CELL(i,j)-MDIST(i,j))./SDIST(i,j)).^2)

답변 (1개)

Walter Roberson
Walter Roberson 2020년 1월 31일
for i = 1:nlat
for j = 1:nlon
CELL = DIST{i,j} ; % HERE I TRIED TO TREAT EVERY SINGLE CELL AS AN INDIVIDUAL ARRAY
PDF(i,j) = (1./(SDIST(i,j)*2*pi))*exp(-0.5*((CELL(i,j)-MDIST(i,j))./SDIST(i,j)).^2); % CALCULATING GAUSSIAN PDF
LD(i,j) = exp(MDIST(i,j)+0.5*(SDIST(i,j).^2)); % CALCULATING LOGARITMIC PDF
end
end
  댓글 수: 1
Sevil Cansu Yildirim
Sevil Cansu Yildirim 2020년 1월 31일
편집: Sevil Cansu Yildirim 2020년 1월 31일
Index in position 2 exceeds array bounds.
Error in all_velocities4 (line 56)
PDF(i,j) = (1./(SDIST(i,j)*2*pi))*exp(-0.5*((CELL(i,j)-MDIST(i,j))./SDIST(i,j)).^2); % CALCULATING GAUSSIAN PDF,
sorry but error message again

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

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by