From: UrbGru Grundström on 26 May 2010 05:07 I have a question if it's possible to make a specific code shorter, i.e I'm looking for a way to simplify the code. Now the code looks like this: load splitmu_no_steerback_mna50kph_1_200kpa Test_Plot_SteerAngle_Speed plot (sync_Var_SA(:,1), sync_Var_SA(:,2)) hold on plot (sync_Var_VS(:,1), sync_Var_VS(:,2)) load splitmu_no_steerback_mna50kph_2_200kpa Test_Plot_SteerAngle_Speed plot (sync_Var_SA(:,1), sync_Var_SA(:,2), 'r') hold on plot (sync_Var_VS(:,1), sync_Var_VS(:,2), 'r') load splitmu_nosteerback_mna50kph_1_igen.mat Test_Plot_SteerAngle_Speed plot (sync_Var_SA(:,1), sync_Var_SA(:,2), 'g') hold on plot (sync_Var_VS(:,1), sync_Var_VS(:,2), 'g') load splitmu_nosteerback_ugr50kph_1_200kpa Test_Plot_SteerAngle_Speed plot (sync_Var_SA(:,1), sync_Var_SA(:,2), 'y') hold on plot (sync_Var_VS(:,1), sync_Var_VS(:,2), 'y') This shows 4 files being processed, but there will be more files. It's the same processing of data in "Test_Plot_SteerAngle_Speed", and the same variables are plotted, only with data from different files. Is there a way to make some kind of loop that loads a file, then process the data and then makes the plot. Then loads a new file, process the data and makes the plot in a different color from the previous one. The different curves must be in the same plot.
From: us on 26 May 2010 05:41 "UrbGru Grundström" <ubbe1000(a)hotmail.com> wrote in message <htiobo$nmv$1(a)fred.mathworks.com>... > I have a question if it's possible to make a specific code shorter, i.e I'm looking for a way to simplify the code. > > Now the code looks like this: > > > load splitmu_no_steerback_mna50kph_1_200kpa > Test_Plot_SteerAngle_Speed > plot (sync_Var_SA(:,1), sync_Var_SA(:,2)) > hold on > plot (sync_Var_VS(:,1), sync_Var_VS(:,2)) > > load splitmu_no_steerback_mna50kph_2_200kpa > Test_Plot_SteerAngle_Speed > plot (sync_Var_SA(:,1), sync_Var_SA(:,2), 'r') > hold on > plot (sync_Var_VS(:,1), sync_Var_VS(:,2), 'r') > > load splitmu_nosteerback_mna50kph_1_igen.mat > Test_Plot_SteerAngle_Speed > plot (sync_Var_SA(:,1), sync_Var_SA(:,2), 'g') > hold on > plot (sync_Var_VS(:,1), sync_Var_VS(:,2), 'g') > > load splitmu_nosteerback_ugr50kph_1_200kpa > Test_Plot_SteerAngle_Speed > plot (sync_Var_SA(:,1), sync_Var_SA(:,2), 'y') > hold on > plot (sync_Var_VS(:,1), sync_Var_VS(:,2), 'y') > > > This shows 4 files being processed, but there will be more files. > > It's the same processing of data in "Test_Plot_SteerAngle_Speed", > and the same variables are plotted, only with data from different files. > > Is there a way to make some kind of loop that loads a file, then process the data and then makes the plot. Then loads a new file, process the data and makes the plot in a different color from the previous one. The different curves must be in the same plot. a hint: http://matlabwiki.mathworks.com/MATLAB_FAQ#How_can_I_process_a_sequence_of_files.3F us
From: UrbGru on 26 May 2010 09:43 Well, I guess that didn't help me in my problem... The files can't have the same name and just be sequentially numbered. And the second part that said: "If instead you want to process all the files whose name matches a pattern in a directory, you can use DIR to select the files:" But it uses the command "imread" which works just for pictures, right?
From: dpb on 26 May 2010 10:05 UrbGru wrote: > Well, I guess that didn't help me in my problem... > > The files can't have the same name and just be sequentially numbered. > > And the second part that said: "If instead you want to process all the > files whose name matches a pattern in a directory, you can use DIR to > select the files:" > > But it uses the command "imread" which works just for pictures, right? There's no reason to not use the filenames returned for whatever purpose you want; there's nothing magic about imread(); it could just as easily be fopen() or the filename passed to textscan() or whatever... Live a little...be creative and expand on a theme!!! (Even read the veryfinemanual and examples if all else fails... :) ) --
From: Steven Lord on 26 May 2010 10:17 "dpb" <none(a)non.net> wrote in message news:htj9ul$r36$1(a)speranza.aioe.org... > UrbGru wrote: >> Well, I guess that didn't help me in my problem... >> >> The files can't have the same name and just be sequentially numbered. >> >> And the second part that said: "If instead you want to process all the >> files whose name matches a pattern in a directory, you can use DIR to >> select the files:" >> >> But it uses the command "imread" which works just for pictures, right? > > There's no reason to not use the filenames returned for whatever purpose > you want; there's nothing magic about imread(); it could just as easily be > fopen() or the filename passed to textscan() or whatever... I just clarified that section of that FAQ entry. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
|
Next
|
Last
Pages: 1 2 Prev: value from Simulink in GUI Next: Artefact removing (how to zoom while using getpts?) |