Matlab 错误:输出参数";俱乐部“区域”;(可能还有其他人)在呼叫期间未分配给
有2个矩阵,尺寸为1440行乘241列。第一个矩阵用其面积填充每个单元格,第二个矩阵包含从0到871的值。这些单元被分组,值1到871表示不同的组,即组1由10个相邻单元组成,组2由20个相邻单元组成,等等 我想构建第三个矩阵,871行乘以1列,列出第二个矩阵中每组单元格的面积,面积是通过对第一个矩阵中的相关单元格求和计算出来的 我尝试运行一个函数,但始终出现以下错误:Matlab 错误:输出参数";俱乐部“区域”;(可能还有其他人)在呼叫期间未分配给,matlab,function,Matlab,Function,有2个矩阵,尺寸为1440行乘241列。第一个矩阵用其面积填充每个单元格,第二个矩阵包含从0到871的值。这些单元被分组,值1到871表示不同的组,即组1由10个相邻单元组成,组2由20个相邻单元组成,等等 我想构建第三个矩阵,871行乘以1列,列出第二个矩阵中每组单元格的面积,面积是通过对第一个矩阵中的相关单元格求和计算出来的 我尝试运行一个函数,但始终出现以下错误: clear all clear load Clusters_28Aug.mat; AR = A>0; U = C
clear all
clear
load Clusters_28Aug.mat;
AR = A>0;
U = Cluster_Area(AR)
集群_区域(第13行)中的错误i=1;
调用时未指定输出参数“Clus_区域”(可能还有其他)
我以为变量是在函数中赋值的。我怎样才能解决这个问题
这是我的密码:
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
你不是说
if AR(i,j)>0
我不确定当表达式生成数组时if语句的语义是什么,但我认为它可能要求表达式的所有元素都为true