changing a variable in an equation

조회 수: 4 (최근 30일)
Paul Rogers
Paul Rogers 2020년 12월 11일
편집: Paul Rogers 2020년 12월 11일
Hi, I wrote this little piece of code to evaluate
mass_flow
I then find out I have mass_flow, and I need to evaluate ER. Is there an automatic way to do so without doing the math?
clear
clc
close all
load
datas.mat
k = 1.4; %Gas constant ratio, cp/cv()
R = 287.05; %ideal gas constant [J/Kg*K]
A_eff = .0069; %[m^2]
mass_flow = phi_10Hz; %expansion ratio
mass_flow = A_eff.*((k./R).^0.5).*((1./E_R).^(1/k)).*(((2./k-1).*(1-(1./E_R).^((k-1)./k))).*0.5);
figure()
plot(E_R,mass_flow)
In attached the datas.mat you need to run the file
  댓글 수: 4
Alan Stevens
Alan Stevens 2020년 12월 11일
편집: Alan Stevens 2020년 12월 11일
Ah yes. Because you want to plot mass-flow agaist E_R, I assume you want to find a different E_R for each value of mass_flow (rather than a single overall best-fit), in which case one way is to do the following:
load datas.mat
k = 1.4; %Gas constant ratio, cp/cv()
R = 287.05; %ideal gas constant [J/Kg*K]
A_eff = .0069; %[m^2]
mass_flow = phi_10Hz; %expansion ratio
mass_flowfn = @(E_R) A_eff.*((k./R).^0.5).*((1./E_R).^(1/k)).*(((2./k-1).*(1-(1./E_R).^((k-1)./k))).*0.5);
E_R = zeros(1,numel(mass_flow));
ER0 = 1; % Initial guess
for i = 1:numel(mass_flow)
E_R(i) = fminsearch(@(ER)fn(ER,mass_flowfn,mass_flow(i)),ER0);
ER0 = E_R(i);
end
figure()
plot(E_R,mass_flow)
function F = fn(ER, mass_flowfn, mass_flow)
F = norm(mass_flowfn(ER) - mass_flow);
end
Most of the values of E_R seem to be the same, so perhaps this isn't the best method!
Paul Rogers
Paul Rogers 2020년 12월 11일
편집: Paul Rogers 2020년 12월 11일
mmm, thanks, but basically what I wanted is to write the following euation as a function of m and not ER like it is now.
Since it's pretty rought I wanted to know if there is some matlab tricks I don't know to do so.
In short I have m=f(ER), and I want ER=f(m)

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Computations에 대해 자세히 알아보기

태그

제품


릴리스

R2014b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by