comp.soft-sys.matlab - The MathWorks calculation and visualization package.
Hi, I am using a function to calculate the velocities given distances and times - the function has this form : function [t, hvel, whichderiv] = derivative_kp(t, h_parm, whichderiv, s) where t = time h_parm = distances whichderiv = level of derivative hvel = velocity Both t and h_parm are 2-d arrays (R x C) - what is a good way to use this function in a loop in that case? When I used a for loop for this function, all values for hvel in the output get overwritten for every iteration ... I want to save the value from hvel for every iteration to result in a 2-d array with the same dimensions as h_parm (R x C). Could someone please help? Thanks much!
Hi, I have a coded a loop in which the final "results" are a row of numbers that are related to "j": for j = 1:N, PictureName2 = PictureName (j); X_Coordinate2 = X_Coordinate (j); results = [PictureName2, j, X_Coordinate2]; end; I would like to be able to output one Excel file that has N rows (i.e., one row represents each loop through the code) with three columns corresponding to the three values in "results". Is this possible to do? (If I just save the results at the end of this code, I only save the final run through the loop when j=N). Thanks!
Hi, I've tried example using fprintf command (given in this forum) & it worked. But when I tried with my code, this message came out ??? Error using ==> fprintf Invalid file identifier -1. Error in ==> testsave at 16 fprintf(fid,'%d\n',meanabs) This is my code. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %function function stat = simpstat (res) %Look at the data from this file rex = embuffer(); %open file fid = fopen('c:\test.mat','wt'); %for loop for i=1:1000 res=rex(:,i); % to find Mean Absolute Value tot = sum(abs(res)); meanabs = tot/200; fprintf(fid,'%d\n',meanabs); end fclose(fid); +++++++++++++++++++++++++++++++++++++++++++++++++++++ please advice.
Hi, If we set Display option to be 'iter', fminsearch will display output at each iteration. But when I have a lot of calls to fminsearch, I want to automatically save each iteration output into a file or variable for late checkup after the program stops, but it seems that the output of each iteration can only be displayed in the main window. For example, we can have the following result displayed in main window: Iteration Func-count min f(x) Procedure 0 1 1.31656e+008 1 2 1.31656e+008 initial simplex 2 4 1.24762e+008 contract inside 3 6 6.619e+007 contract inside 4 8 6.619e+007 contract inside 5 10 6.619e+007 contract inside .... but how can I automatically save this output into a file or variable? Do you know how to save the result of each iteration but not display it in the main window? Thanks a lot for your advice in advance. Mutang