Replacing values inside ODE code
Afficher commentaires plus anciens
I'm a physics student and I'm working on a code that models rotational velocities of calcite crystals from a second order differential equation. Here is the part of the code I'm having issues with.
for i=1:Nd+1;
d = dmin:deltad:dmax;
for j= 1:NPhi+1;
Phi= Phi_min:Delta_Phi:Phi_max;
[t,x] = ode45(@CPOT,[0 tmax],x0);
velocity = x;
velocity(:,1) = [];
velocity_matrix(i,j) = x(end);
end
end
In this part of the code, I'm extracting the last velocity value and putting it into another matrix called velocity_matrix. For each pass, I want the value of 2 variables (d and Phi) to change, so that I get a final velocity value for each combination of d and phi values. That way, the velocity_matrix can be graphed as a function of d and phi on a contour plot. I'm not sure how to make it so the d and phi values change within the CPOT file for each loop through as I can't write them as matrices inside the CPOT m-file
Réponses (1)
bym
le 6 Août 2011
0 votes
perhaps you can use anonymous functions as explained here:
Catégories
En savoir plus sur Ordinary Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!