Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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)

Risposte (1)

Walter Roberson
Walter Roberson il 31 Gen 2020
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 Commento
Sevil Cansu Yildirim
Sevil Cansu Yildirim il 31 Gen 2020
Modificato: Sevil Cansu Yildirim il 31 Gen 2020
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

Accedi per commentare.

Categorie

Scopri di più su Data Distribution Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by