How to add more than one conditions for an ode45 problem?

3 visualizzazioni (ultimi 30 giorni)
Hi, This is my code in which 'b','phi' and 'VOLUME' are present:
format long
%input your entries here
density=1;%kg/m3
gravity=9;%m/s2
tension=46.5;%kg/s2
beta=(density*gravity)/tension;
for b=0:0.5:2
xini=1e-10;
zini=1e-10;
phiini=0;
phifin=150;
stepsize=1e-2;
V=1;
%code begins
phi1=deg2rad(phiini);
phi2=deg2rad(phifin);
f=@(phi,x)[b*cos(phi)/(2+beta*(x(2)/b)-(sin(phi)/(x(1)/b)));(b*sin(phi))/(2+beta*(x(2)/b)-(sin(phi)/(x(1)/b)))];
[phi,xa]=ode45(f,[phi1:stepsize:phi2],[xini zini]);
%Volume calculation
X=xa(:,1);
Z=xa(:,2);
VOLCUM=cumtrapz(Z,X);
position=find(VOLCUM<=V,1,'last');
VOLUME=VOLCUM(position)
My intention is to find the 'b' that gives me the required 'VOLUME' as well as 'phi' In other words, I want the code to loop until it gives me that 'b' which has 'VOLUME=1' and 'phi=60'. I am not sure how to proceed.
  2 Commenti
Jan
Jan il 12 Mag 2018
Modificato: Jan il 12 Mag 2018
The question is not clear. You want to get a "required V", but V is defined as a variable already. while is not an "operator" and I have no idea, where you want to apply &&. It is not clear, why you apply cumtrapz after the integration. Are you sure that this is useful?
Maybe you want to write a single-shooting method to estimate a parameter?
By the way: a:b:c is a vector already. There is no need to use [] for a horizontal concatenation.
Purush otham
Purush otham il 12 Mag 2018
Hi thanks for your comment. Edited the original question. The three major parameters here are: 'phi','b' and 'VOLUME'.
My intention is to predefine 'VOLUME' and 'phi' and get the required 'b'.
The use of cumtrapz here is to find the area under plot. (%The final value of cumtrapz is same as trapz)

Accedi per commentare.

Risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by