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

2 次查看(过去 30 天)
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
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