Plot 4D function with respect to two variables and a parameter

6 vues (au cours des 30 derniers jours)
UserCJ
UserCJ le 30 Avr 2022
Commenté : Torsten le 1 Mai 2022
There is a differential equation . I would like to change the value of parameter value of A from to and plot C against and Aas shown in the picture below.
I tried it in MATLAB as follows:
DY3 = {};
PARAMA = linspace(-0.067,0.067,20);%parameter A
for i=1:numel(PARAMA)
param.A = PARAMA(i);
otherparams;%m file that contains other parameters
Tend = 200;
Nt = 100;
RHS = @(t,x) func(t,x,param,1);
%Execution-----------------------------------------------------------------
x0 = [0.001,0.004,0.006]; %Initial condition
t = linspace(0,Tend,Nt); %TSPAN
options = odeset('RelTol',1e-4,'AbsTol',1e-4);
sol = ode45(RHS, t, x0, options);
[y,yp] = deval(sol,t);
x1 = y(1,:);
x2 = y(2,:);
dy3 = yp(3,:);%evaluate derivative
DY3{i} = dy3;
end
M = cell2mat(DY3);
[X1,X2,PARAMA] = meshgrid(x1,x2,PARAMA);
[faces,verts] = isosurface(x1,x2,PARAMA,M,0);
Whe I run this code I get the following error message.
Error using isosurface (line 79)
V must be a 3D array.
Can someone please help me to resolve this? Thank you very much!

Réponse acceptée

Torsten
Torsten le 30 Avr 2022
I don't think that you really want to solve the differential equation.
To get volumetric data for DY3, you will have to do
  1. Specify ranges for x1, x2 and parama using the linspace command.
  2. Use [X1,X2,PARAMA] = meshgrid(x1,x2,parama) to get volumetric input data.
  3. Evaluate your function F as DY3 = F(PARAMA,B,C,X1,X2)
  4. Plot the isosurface to the value 1e-4, e.g.
  2 commentaires
UserCJ
UserCJ le 1 Mai 2022
Modifié(e) : UserCJ le 1 Mai 2022
@Torsten Thanks for your answer.
and are variables in the system of three differential equations, so I think I anyway need to solve the system to get values for these variables. If this is the case, what do you think how I could plot the figure?
For the same code above, I included the meshgrid term.
[X1,X2,PARAMA] = meshgrid(x1,x2,PARAMA);
[faces,verts] = isosurface(x1,x2,PARAMA,DY3,1e-4);
But I got the following error. I checked the sizes, and found out that the sizes of and are similar, but the size of is different. Is this a reason for this error?
M = cell2mat(DY3);
Error using isosurface (line 79)
V must be a 3D array.
Torsten
Torsten le 1 Mai 2022
Isosurfaces can be drawn from 3d-data (i.e. data that are given on a volume).
dy3 = f(x1,x2,Parama) can be 3d data if x1, x2 and Parama are independently prescribed and f is then used to evaluate them to get dy3.
In an ODE solution, x1 and x2 don't span a surface (2d), but only give a curve (1d). This means that DY3 is not 3d as necessary to get isosurfaces, but only 2d - thus itself a surface.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by