Output argument "Clus_Area" (and maybe others) not assigned during call to
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Have 2 matrices, dimensions 1440 rows by 241 columns. First matrix populates each cell with its area, and the second contains values from 0 to 871. These cells are grouped, and values 1 to 871 represent different groups, ie group 1 comprised of 10 neighboring cells, group 2 comprised of 20 neighboring cells, etc.
Want to build a third matrix, 871 rows by 1 column, that lists the area of each group of cells from the second matrix, with the areas calculated by summing the relevant cells from the first matrix.
Tried running function, but keep getting this error: >> clear all >> clear >> load Clusters_28Aug.mat; >> AR = A>0; >> U = Cluster_Area(AR) Error in Cluster_Area (line 13) i = 1;
Output argument "Clus_Area" (and maybe others) not assigned during call to "C:\Users\kquinn\Documents\UCLA\Data\2005\Cluster_Area.m>Cluster_Area".
Function code:
function Clus_Area = Cluster_Area(AR) % %Summer 2013 Project % %Purpose: To determine the area of each cluster, by adding up the individual areas of each cell within a cluster. % Input % AR(i,j) = clusters ID'd, on a 1440 x 241 matrix % % Output % Clus_Area(i,j) = area of each cluster, single column vector, indexed by cluster #
i = 1; j = 1;
for i = 1:1440; %For all longitudes
for j = 1:120; %For 30S to Equator, convert 0.25 deg lon to km, varies by latitude
if AR > 0;
b_1 = (111.41288*cosd(abs((0.25*(j+239))-90)))-(0.0935*cosd(abs(3*((0.25*(j+239))-90))))+(0.00012*cosd(abs(5*((0.25*(j+239))-90))));
b_2 = (111.41288*cosd(abs((0.25*(j+240))-90)))-(0.0935*cosd(abs(3*((0.25*(j+240))-90))))+(0.00012*cosd(abs(5*((0.25*(j+240))-90))));
%Use area formula for trapezoid A = 1/2 h (b_1+b_2), where h = 27.8km
Area_cell = (((0.5)*27.8*1000)*((b_1+b_2)*1000)); %Ans converted to m^2
%Add up cell areas to get cluster area
Clus_Area(i,j) = sum(Area_cell);
disp('Clus_Area')
%Populate Grid_LAT_LON with area of each cell
%Grid_LAT_LON(i,j) = Area_cell;
end
end
for j = 121:241; %For Equator to 30N, convert 0.25 deg lon to km, varies by latitude
if AR > 0;
b_1 = (111.41288*cosd(((0.25*(j+239))-90)))-(0.0935*cosd((3*((0.25*(j+239))-90))))+(0.00012*cosd((5*((0.25*(j+239))-90))));
b_2 = (111.41288*cosd(((0.25*(j+240))-90)))-(0.0935*cosd((3*((0.25*(j+240))-90))))+(0.00012*cosd((5*((0.25*(j+240))-90))));
%Use area formula for trapezoid A = 1/2 h (b_1+b_2), where h = 27.8km
Area_cell = (((0.5)*27.8*1000)*((b_1+b_2)*1000)); %Ans converted to m^2
%Add up cell areas to get cluster area
Clus_Area(i,j) = sum(Area_cell);
disp('Clus_Area')
%Populate Grid_LAT_LON with area of each cell
%Grid_LAT_LON(i,j) = Area_cell;
end
end
end
Z = Clus_Area(i,j);
end
0 Kommentare
Antworten (1)
Richard Brown
am 31 Jul. 2013
Check that the line
if AR > 0
is doing what you intend. This will only evaluate if all entries of AR are positive. The error message you're getting is showing that Clus_Area is never actually filled at all, and it's that if statement that is likely preventing it.
Siehe auch
Kategorien
Mehr zu Cluster Analysis and Anomaly Detection finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!