Saving variables in a function

조회 수: 2 (최근 30일)
Paul Rogers
Paul Rogers 2021년 2월 15일
댓글: Walter Roberson 2021년 2월 15일
Hi everyone,
I am calling this function where I get in output the time t and the matrix y:
function [ dy ] = greitzer( t,y,P)
%% Energy Losses
deltahfi = P.kf.*(y(1).^2); %Impeller Friction losses
deltahfd = P.kfd.*(y(1).^2); %Diffuser Friction losses
%% Throttle valve's parameters
%% con lo stesso Delta da una parte e dall'altra
deltaideal = P.sigma*(P.U2^2); %Deltah0c,ideal
%% Lossees
deltahii = 0.5.*((P.U1-...
((cot(P.beta1b).*y(1))/(P.ro1*P.Ai))).^2); %Impeller Incidence Loss
deltahid = 0.5.*(((P.sigma*P.D2*P.U1)/P.D1)-...
((y(1).*cot(P.alfa2b))/(P.ro1*P.Ad))).^2; %Diffuser Incidence Loss
deltaloss = deltahii+...
deltahid+deltahfi+deltahfd;
% deltah0c = deltaideal-...
% deltaloss-deltan; %deltah0c
%% Efficiency
eta = deltaideal./(deltaideal+deltaloss)-P.deltan;
%% Pressure Rise in the Compressor
psi_c =((1+((eta.*deltaideal)/(P.T01*P.cp))).^(P.k/(P.k-1)));
%% Greitzer's System
gamma_T = @(t) P.Amplitude*sin(P.w*t)+P.b; % valve's function
dy = [ P.B*(psi_c-y(2));
(1/P.B.*(y(1)-gamma_T(t).*(y(2).^0.5))) ];
end
what I need now it that it also saves psi_c and gamma_T(t).*(y(2).^0.5)
I put the files in attached so you don't have to copy and paste

채택된 답변

Walter Roberson
Walter Roberson 2021년 2월 15일
  댓글 수: 2
Paul Rogers
Paul Rogers 2021년 2월 15일
then basically once I get "t" and "y" I can evaluete them post-function after the call?
Walter Roberson
Walter Roberson 2021년 2월 15일
Yes.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Fluid Mechanics에 대해 자세히 알아보기

제품


릴리스

R2014b

Community Treasure Hunt

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

Start Hunting!

Translated by