find the differences between two funtions
13 ビュー (過去 30 日間)
古いコメントを表示
I have two functions as follows:
v=g*b/(2*pi*(1-nu)).*x.*(x.^2-y.^2)./(x.^2+y.^2).^2;
P=-g*b/(2*pi*(1-nu)).*(x./(x.^2+(y+zi).^2)-2.*x.*y*(y+zi)./(x.^2+(y+zi).^2).^2)
g=46e9;
b=0.2556e-9;
nu=0.33;
zi=0.155e-9;
y=1e-8;
x=2e-9:1e-10:2e-7;
I want to find that at what amount of x, the dfference between v and p is equal to 0.2
0 件のコメント
回答 (1 件)
Sreelakshmi S.B
2019 年 3 月 6 日
You can try the following code:
g=46e9;
b=0.2556e-9;
nu=0.33;
zi=0.155e-9;
y=1e-8;
x=2e-9:1e-10:2e-7;
v=@(x) g*b/(2*pi*(1-nu)).*x.*(x.^2-y.^2)./(x.^2+y.^2).^2;
P=@(x) -g*b/(2*pi*(1-nu)).*(x./(x.^2+(y+zi).^2)-2.*x.*y*(y+zi)./(x.^2+(y+zi).^2).^2);
%creating a function handle for calculating diff
diff = @(x) v(x) - P(x);
allZeros = [];
for x=2e-9:1e-10:2e-7
if(abs(round(diff(x),1))==0.2)
allZeros = [allZeros,x];
end
end
%allZeros will have all values of x for which diff is 0.2
However the values you've specified for x won't give you any values with diff. as 0.2 since the step size for x is too large.You can try observing where the diff is crossing over 0.2 and try reducing the step size.You can also plot the graph for 'P-v' and observe where it crosses 0.2.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!