To find answer using matlabfunction
이전 댓글 표시
I am using matlabfunctions to try and solve for an equation for many possible variable combination, the script is executing but I am not sure it is what I am expecting.
Here is the program,
clear;clc;close all;
syms r1 r2 d ni
f = matlabFunction((ni-1).*((1./r1)-(1./r2)+(((ni-1).*d)./(ni.*r1.*r2))));
n = 100;
r1a = linspace(14.8e-3,15e-3,n);r2a = linspace(-14.8e-3,-15e-3,n);d = linspace(4e-3,4.1e-3,n);ni=linspace(1.51,1.518,n);
[R1,R2,D,N] = ndgrid(r1a,r2a,d,ni);
p = feval(f,R1,R2,D,N);
F = 1/p;
ind = find (F>0.014 & F<0.015);
Freq = F(ind);
r1req = R1(ind);I am
r2req = R2(ind);
dreq = D(ind);
nreq = N(ind);
Ar = [Freq,r1req,r2req,dreq,nreq];
What I am expecting here is the different combinations of n, r1, r2, and d thar gives f in range of 0.014 to 0.015
I am getting values till p right but while calculation F as 1/p I am getting values that are different to what I am anticipating.
If I am looking for F for the values of r1 = 15e-3;r2 = -15e-3;d = 4.049e-3;ni=1.5168; with above code I am getting 0.002 but with below code it is 0.015
clc;clear;close all;
r1 = 15e-3;r2 = -15e-3;d = 4.049e-3;ni=1.5168;
p = (ni-1).*((1./r1)-(1./r2)+(((ni-1).*d)./(ni.*r1.*r2)));
f = 1/p;
So how to correct the top code to get accurate f values.
Any kind of help is highly appreciable.
Thank you and regards.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!