简体   繁体   English

MATLAB:如何在一定输入压力范围内绘制三次方程式

[英]MATLAB: How to plot a cubic expression for certain range of input pressure

I have a cubic expression here 我在这里有一个三次表达

这里的三次表达

I am trying to determine and plot δ 𝛿 in the expression for P values of 0.0 to 5000. I'm really struggling to get the expression for δ in terms of the pressure P . 我试图确定并在0.0〜5000我真的努力得到的压力P的条款δ表达P值表达剧情δδ。

clear all;
close all;

t = 0.335*1e-9;
r = 62*1e-6;
delta = 1.2*1e+9;
E = 1e+12;
v = 0.17;
P = 0:100:5000

P = (4*delta*t)*w/r^2 + (2*E*t)*w^3/((1-v)*r^4);

I would appreciate if anyone could provide pointers. 如果有人可以提供指针,我将不胜感激。

What you want is the functional inverse of your expression, ie, δ 𝛿 as a function of P . 你想要什么功能逆的表达,即δδ作为P的函数。 Since it's a cubic polynomial , you can expect up to three solutions (roots) for a give value of P . 由于它是三次多项式 ,因此对于给定的P值,您最多可以期望三个解(根)。 However, I'm guessing that you're only interested in real-valued solutions and nonnegative values of P . 但是,我猜测您只对P的实值解决方案和非负值感兴趣。 In that case there's just one real root for each value of P . 在这种情况下,每个P值只有一个实根。

Given the values of your parameters, it makes most sense to solve this numerically using fzero . 在给定参数值的情况下,最有意义的是使用fzero数值fzero Using the parameter names in your code (different from equations): 在代码中使用参数名称(与方程式不同):

t = 0.335*1e-9;
r = 62*1e-6;
delta = 1.2*1e9;
E = 1e12;
v = 0.17;
f = @(w,p)2*E*t*w.^3/((1-v)*r^4)+4*delta*t*w/r^2-p;

P = 0:100:5000;
w0 = [0 1]; % Bounded initial guess, valid up to very large values of P
w_sol = zeros(length(P),1);
for i = 1:length(P)
    w_sol(i) = fzero(@(w)f(w,P(i)),w0); % Find solution for each P
end

figure;
plot(P,w_sol);

You could also solve this using symbolic math: 您也可以使用符号数学来解决此问题:

syms w p
t = 0.335*sym(1e-9);
r = 62*sym(1e-6);
delta = 1.2*sym(1e9);
E = sym(1e12);
v = sym(0.17);
w_sol = solve(p==2*E*t*w^3/((1-v)*r^4)+4*delta*t*w/r^2,w);

P = 0:100:5000;
w_sol = double(subs(w_sol(1),p,P)); % Plug in P values and convert to floating point

figure;
plot(P,w_sol);

Because of your numeric parameter values, solve returns an answer in terms of three RootOf objects , the first of which is the real one you want. 由于您的数值参数值, solve将根据三个RootOf对象返回一个答案,第一个是您想要的真实对象

I suggest two simple methods. 我建议两种简单的方法。

  1. You evaluate P as a function of delta then you plot(P,delta) . P评估为delta的函数,然后plot(P,delta) This is quick and dirty but if all you need is a plot it will do. 这既快速又肮脏,但是如果您只需要绘图,它将可以完成。 The inconvenience is that you may to do some guess-and-trial to find the correct interval of P values, but you can also take a large enough value of delta_max and then restrict the x-axis limit of the plot. 给您带来不便的是,您可以做一些猜测来找到正确的P值间隔,但也可以取足够大的delta_max值,然后限制绘图的x轴限制。

  2. Your function is a simple cubic, which you can solve analytically ( see here if you are lost ) to invert P(delta) into delta(P) . 您的函数是一个简单的三次方,您可以解析地求解( 如果丢失,请参见此处 ),以将P(delta)转换为delta(P)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM