【问题标题】:Solving a three-variable implicit function using MATLAB使用 MATLAB 求解三变量隐式函数
【发布时间】:2014-03-15 02:38:00
【问题描述】:

我想在 MATLAB 中从函数 tan(n*theta1) + tan(n*theta2) + tan(n*thetas)= 0 绘制 n 与 theta1;其中 n、theta1 和 theta2 是变量,并且给出了 thetas。谁能指点一下如何做到这一点?

我尝试过使用 ezplot。没用。

接下来,我使用了这段代码,

c = 1;
thetas = pi/4;
for n = 1.01:0.01:3.50
    for theta1 = pi/2 : 0.01 : 5*pi/6
        for theta2 = 0: 0.01: pi/2
            if(tan(n*theta1) + tan(n*theta2) + tan(n*thetas) >= -0.0001 && tan(n*theta1) + tan(n*theta2) + tan(n*thetas) <= 0.0001 && (n*theta1) ~= pi/2 ...
                    && (n*theta2) ~= pi/2 && (n*thetas) ~= pi/2)
                ns(c) = n;
                theta1s(c) = theta1;
                theta2s(c) = theta2;
                c = c + 1;
            end
        end
    end
end

我尝试使用 plot 命令绘制结果。也没有成功。大多数情况下,对于每个给定的 thetas 值,该图应该是三个不同的曲线。

谁能帮忙?

【问题讨论】:

    标签: matlab


    【解决方案1】:

    这样的方法可能有用吗? -

    %%// Data (Random numbers)
    thetas_array = [2 4 6]; %// Put different thetas here
    theta2 = 2:2:20;
    n = 1:10;
    
    figure,
    for k = 1:numel(thetas_array)
    
        thetas = thetas_array(k);
    
        %%// Since tan(n*theta1) + tan(n*theta2) + tan(n*thetas)= 0;
        theta1 =  (1./n).*atan(- tan(n.*theta2) - tan(n.*thetas));
    
        subplot(3,1,k), plot(n,theta1), xlabel('n'), ylabel(strcat('theta1 [thetas = ',num2str(thetas),']'));
    end
    

    输出

    【讨论】:

    • 除此代码需要等维 n 和 theta2 向量外,此代码可以正常工作。但根据一篇论文,我应该在每个 thetas 中得到 3 条线。我没有得到。
    • 所以您希望只有一张图包含三个 theta 的所有三个图?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-03
    • 1970-01-01
    • 2014-02-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多