MATLAB:为什么我没有得到任何输出?

时间:2017-02-10 12:45:13

标签: matlab if-statement for-loop output

为什么我的代码不计算变量cos_theta,然后计算theta

代码:

alpha = alpha_min:alpha_step:alpha_max;
cos_theta_0 = -1./(2.*alpha)+sqrt(1.+1./(4.*alpha.^2));
theta_0 = acos(cos_theta_0);
hmax = (sqrt(1+4.*alpha.^2)-1)./(2.*log(2));

for h = 1:(K-2);
    if h<= hmax;
    cos_theta(h,:) = cos_theta_0- h.*log(2)./alpha;
    theta(h,:) = acos(cos_theta(h,:));
    else break;
    end 
end

1 个答案:

答案 0 :(得分:1)

目前尚不清楚你在这里要做什么:

h <= hmax

您正在将常量'h'与矢量'hmax'进行比较。