Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running script for different datafiles consecutively

Status
Not open for further replies.

truetears

Industrial
Mar 30, 2013
6
My script is:

Code:
 clc;
  clear;
  
  % Import data
  % PD: probability of default
  % CM: covariance matrix
  % DT: default threshold
  
  PD = xlsread('Book1.xlsx','PD');
  CM = xlsread('Book1.xlsx','COV');
  DT = xlsread('Book1.xlsx','DT');
  
  Original_PD = PD;                       %Store original PD
  LM_rows = size(PD,1)+1;                 %Expected LM rows
  LM_columns = size(PD,2);                 %Expected LM columns
  LM_FINAL = zeros(LM_rows,LM_columns);    %Dimensions of LM_FINAL
  
  for i = 1:size(PD,2)
      PD = Original_PD(:,i);
      options = optimset('Display','iter');
      x0 = zeros(size(PD,1)+1,1);
      [LM,fval,exitflag] = fsolve(@(x)ConstLM(x,PD,CM,DT), x0, options);
      LM_FINAL(:,i) = LM;
  end

Now I have many datafiles, namely:

Code:
Book1.xlsx

  Book2.xlsx

...

  Book100.xlsx

Currently I am running the script manually for each Book, how can I run let it run automatically for all 100 Book's?

The final result I am after is the LM_FINAL variable which is a 3x1348 matrix of values. When automated for 100 Book's, I will end up with 100 sets of 3x1348 matrix of values, ie, 300x1348 matrix of values. I would like to display this entire 300x1348 matrix of values in one variable called LM_FINAL_ALL.

Lastly, if required, an example of my datafile Book1 (excel file) can be found here:
Many thanks. If I am unclear please let me know and I will try explain further.
 
Replies continue below

Recommended for you

"Currently I am running the script manually for each Book, how can I run let it run automatically for all 100 Book's? "

?? you write a loop. MATLAB has a full complement of string functions.

TTFN
faq731-376
7ofakss

Need help writing a question or understanding a reply? forum1529
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor