Prev: Bilinear interpolation of a single value
Next: Developing Matlab GUIs and Linking them with C/C++ Programs
From: Mirko on 15 Apr 2010 04:48 Hi to all. I'm following this technical solution posted on matworks website http://www.mathworks.com/support/solutions/en/data/1-196SD/?solution=1-196SD In particular the last part using assignin and evalin. My main function contains this: global counter; counter=1; .. .. .. %ode calling [time,states]=ode113(@rates,[0,final_time],[initial_conditions]); Below the rates function %rates function .. .. .. fp=some calculation.....; global counter; assignin('base','fp',fp); %at every step the fp variable evaluated in the rates function %is stored in the main workspace with the same name evalin('base','fp_array(conteggio,:)=fp;'); %to store the fp variable at every calling of %the ode I store the variable in an array counter=counter+1; %increment of the array position .. .. .. end My problem is that the fp_array I got, contains exactly twice the values of the integrated states I got from ode. For example to obtain the rigth plot of fp_array I have to use plot(time,fp_array(1:2:end,:)); I got what I needed but can someone help me to understand and avoid to obtain the correct fp_array? Why do I obtain twice values for fp_array? Thanks |