Matlab编程器“错误缩进生成的C代码”

时间:2014-02-25 11:46:15

标签: matlab matlab-coder

我正在尝试使用MATLAB编码器将MATLAB代码转换为C ++,但是这个错误出现了:

错误缩进生成的C代码

错误指向函数本身的名称,并且没有更多解释。谁能告诉我这个错误是什么? 这是我想要转换的功能:

function [Report_Clustered,ClusterCounter_new]=InitClusterGenerator_test(Report_In,~,FreqEpsilon,DegreeEpsilon,~,ClusterCounter_old, BlockCount, Report_old)

Report_M = zeros(size(Report_In,1),size(Report_In,2),4);
for i=1:size(Report_In,1)
    for j=1:size(Report_In,2)
        Report_M(i,j,1)=Report_In(i,j,1);
        Report_M(i,j,2)=Report_In(i,j,2);
        Report_M(i,j,3)=0; % Cluster number that the point belongs to.
        Report_M(i,j,4)=0;
Report_In{i,j} 
    end
end
ClusterCounter = 0;
for i=1:size(Report_M,1)
    for j=1:size(Report_M,2)
        if (Report_M(i,j,3) == 0)
            ClusterCounter = ClusterCounter + 1;
            Report_M(i,j,3) = ClusterCounter;
            for ii=1:size(Report_M,1)
                for jj=1:size(Report_M,2)
                    if (Report_M(ii,jj,3) == 0)
                        if (abs(Report_M(i,j,1)-Report_M(ii,jj,1))<FreqEpsilon &&...
                        (abs(Report_M(i,j,2)-Report_M(ii,jj,2)) <DegreeEpsilon ||...
                        abs(-360 + Report_M(i,j,2)-Report_M(ii,jj,2)) <DegreeEpsilon ||...
                        abs(360 + Report_M(i,j,2)-Report_M(ii,jj,2)) <DegreeEpsilon))
                            Report_M(ii,jj,3) = ClusterCounter;
                        end
                    end
                end
            end
        end
    end
end    


if (BlockCount> 20 && ClusterCounter<4)
    warning = 1;
end



        ClusterCounter_new = ClusterCounter;

        %clear Report_new;
        flag = 0;

        Report_new = zeros(ClusterCounter,size (Report_M, 2),4);

        index = zeros(1, ClusterCounter_new);
        for i = 1: size (Report_M, 1)
            for j = 1: size (Report_M, 2)
                for k = 1: ClusterCounter_new
                    if (Report_M(i,j,3) == k)
                        index(1,k) = index(1,k) + 1;
                        Report_new(k,index(1,k), 1:3) = Report_M(i,j,1:3);
                        flag = flag + 1;
                    end
                end

            end
        end



        for j = 1: size (Report_new, 2)
            for i = 1: size (Report_new, 1)
                if (Report_new(i,j,1) == 0)
                    Report_new(i,j,1:3) = Report_new(i,1,1:3);
                end
            end
        end

        %Report_new = Report;


        MedoidF_old = zeros(1, size(Report_old,1));
        MedoidA_old = zeros(1, size(Report_old,1));


        for i=1:size(Report_old,1)
            SumF = 0;
            SumA = 0;
            MinAngle = 361;
            MaxAngle = -1;
            for j=1:size(Report_old,2)
                SumF = SumF + Report_old(i,j,1);
                SumA = SumA + Report_old(i,j,2);
                if Report_old(i,j,2) > MaxAngle
                    MaxAngle = Report_old(i,j,2);
                elseif Report_old(i,j,2) < MinAngle
                    MinAngle = Report_old(i,j,2);
                end
            end
            MedoidF_old(1, i) = SumF/size(Report_old,2);
            if (MaxAngle - MinAngle) > 350
                MedoidA_old(1, i) = 0;
            else
                MedoidA_old(1, i) = SumA/size(Report_old,2);
            end
        end


        MedoidF_new = zeros(1, size(Report_new,1));
        MedoidA_new = zeros(1, size(Report_new,1));


        for i=1:size(Report_new,1)
            SumF = 0;
            SumA = 0;
            MinAngle = 361;
            MaxAngle = -1;
            for j=1:size(Report_new,2)
                SumF = SumF + Report_new(i,j,1);
                SumA = SumA + Report_new(i,j,2);
                if Report_new(i,j,2) > MaxAngle
                    MaxAngle = Report_new(i,j,2);
                elseif Report_new(i,j,2) < MinAngle
                    MinAngle = Report_new(i,j,2);
                end
            end
            MedoidF_new(1, i) = SumF/size(Report_new,2);
            if (MaxAngle - MinAngle) > 350
                MedoidA_new(1, i) = 0;
            else
                MedoidA_new(1, i) = SumA/size(Report_new,2);
            end
        end

        TempCluster = zeros(1, size(Report_new, 1));
        CurrentCluster = ClusterCounter_old;        


        for i = 1: 1: size(Report_new,1)
            for j = 1: 1: size(Report_old,1)
                if (abs(MedoidF_old(1,j)-MedoidF_new(1,i))<FreqEpsilon &&...
                        (abs(MedoidA_old(1,j)-MedoidA_new(1,i))<DegreeEpsilon ||...
                        abs(360 + MedoidA_old(1,j)-MedoidA_new(1,i))<DegreeEpsilon ||...
                         abs(-360 + MedoidA_old(1,j)-MedoidA_new(1,i))<DegreeEpsilon))      %%if the new cluster is the rest of an old cluster use the old one's index for it
                    TempCluster(1,i) = Report_old(j,1,3);
                end
            end

            %%this part is for seperating the clusters which where in the collision state in the past time



            if (TempCluster(1,i)>0) %%if the new cluster is one of the old ones the index should be set
                for j = 1:1:size(Report_new, 2)
                    Report_new(i,j,3) = TempCluster(1,i);
                    Report_new(i,j,4) = 1;% Alive
                end
            else    %%first search if the new cluster is a part of a newly found cluster found before this one
                for j = 1: 1: i-1
                    if (abs(MedoidF_new(1,j)-MedoidF_new(1,i))<FreqEpsilon &&...
                            (abs(MedoidA_new(1,j)-MedoidA_new(1,i))<DegreeEpsilon ||... 
                            abs(360 + MedoidA_new(1,j)-MedoidA_new(1,i))<DegreeEpsilon ||...
                            abs(-360 + MedoidA_new(1,j)-MedoidA_new(1,i))<DegreeEpsilon))       %%if the new cluster is the rest of an old cluster use the old one's index for it
                        TempCluster(1,i) = Report_new(j,1,3);
                    end
                end
            end

            if (TempCluster(1,i)>0) %%if the new cluster is one of the old ones the index should be set
                for j = 1:1:size(Report_new, 2)
                    Report_new(i,j,3) = TempCluster(1,i);
                    Report_new(i,j,4) = 1;% Alive
                end
            else    %%new cluster is just began so it needs a new index
                CurrentCluster = CurrentCluster + 1;
                ClusterCounter_new = CurrentCluster;
                TempCluster(1,i) = CurrentCluster;
                for j = 1:1:size(Report_new, 2)
                    Report_new(i,j,3) = TempCluster(1,i);
                    Report_new(i,j,4) = 1; % Alive
                end
            end

        end


        NewClusters = zeros(1, size (Report_new, 1));
        for i = 1: size(Report_new, 1)
            NewClusters (1,i) = Report_new(i,1,3);
        end

        OldClusters = zeros(1, size (Report_old, 1));
        OldClustersLine = zeros(1, size (Report_old, 1));
        for i = 1: size(Report_old, 1)
            OldClusters (1,i) = Report_old(i,1,3);
            OldClustersLine (1, i) = i;
        end


        NumberOfDead = 0;
        %clear AddDead;
        AddDead = zeros (16,size(Report_new, 2),4);
        if (BlockCount>10)
        for i = 1: size (OldClusters, 2)
            IsDead = 1;
            for j = 1: size (NewClusters, 2)
                if OldClusters(1, i) == NewClusters(1,j)
                    IsDead = 0;
                end
            end
            if (IsDead == 1)
                NumberOfDead = NumberOfDead + 1;
                %clear TempLine;
                TempLine = zeros(1, size(Report_old,2), 4);
                TempLine(1,:,1:3) = Report_old(OldClustersLine(1, i),:,1:3);
                for k= 1: size(TempLine, 2)
                    TempLine(1,k,4) = 0;    % Dead
                end
                TempSize = size(TempLine, 2);
                Thresh = size(Report_new, 2);

                if (TempSize >= Thresh)
                    AddDead (NumberOfDead, 1:Thresh, 1:4) = TempLine(1,1:Thresh, 1:4);
                else
                    for l = 1: Thresh-TempSize
                        TempLine(1, TempSize+l, 1:4) = TempLine(1, TempSize, 1:4);
                    end
                    AddDead (NumberOfDead, 1:Thresh, 1:4) = TempLine(1,1:Thresh, 1:4);
                end
            end
        end
        xR = size (Report_new,1);
        if (NumberOfDead == 0)
            Report_Clustered = zeros (size(Report_new,1),size(Report_new,2),size(Report_new,3));
        else
            Report_Clustered = zeros (size(Report_new,1) + NumberOfDead,size(Report_new,2),size(Report_new,3));
        end
        Report_Clustered (1:size(Report_new,1), :, :) = Report_new(:,:,:);
        for i = 1: NumberOfDead
            Report_Clustered(xR + i, :) = AddDead(i, :);
        end


end

我正在使用matlab 2012a TNX。

1 个答案:

答案 0 :(得分:0)

根据您在评论中所说的内容,您似乎只需要致电

clear functions
在重新编译函数之前从命令行

以允许Matlab覆盖文件。有关详细信息,请参阅this Matlab论坛或clear的文档。