Replacing values inside ODE code

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

Asked:

on 6 Aug 2011

Community Treasure Hunt

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

Start Hunting!