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)
0 个评论
回答(1 个)
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Distribution Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!