0

I have the following problem: I have written six scripts matlab. In the first script, the user must enter the variable n_strati (a number between 1 and 5). The first script allows you to make choices about computing models based on variables known or unknown , and runs them to n_strato=1. The second third fourth and fifth script follow the same procedure , respectively, for the layers 2-3-4-5, but in which the input parameters (not intended as a value) are different. For example:

for Strato1 performs calculations knowing the input variables A B E (and not C D F) , for Strato2 performs calculations knowing A C E (and not B D F) , for Strato3 knowing the variables B D F (and not A C E).

The sixth takes all the variables of the previous scripts and processes them to obtain the final result. The first five scripts save the data using the command:

save Strato1 alpha beta gamma
% etc.

and the sixth script them "stores" with the command:

load Strato1
load Strato2
% etc.

But I have to make sure that:

if n_strati==1 I enter the data and choose the models in script1 jumping scripts 2-3-4-5 and proceeding with the final calculation through the script 6 .

if n_strati==2 I enter the data and choose the models for Strato1 in script1 and Strato2 in script2 jumping scripts 3-4-5 and proceeding with the final calculation through the script 6 . and so on.

I wanted to know: how can I do?

Thank you for your cooperation.

Andrew Janke
  • 23,508
  • 5
  • 56
  • 85

1 Answers1

3

The best way would be avoiding scripts and using functions. Even if you succeed in your plot of using multiple scripts, the code will be a big mess, hard to debug, etc. So the answer is simple:

Say NO to scripts!

It is as easy as adding a signature and declaring your input and output.

Andrey Rubshtein
  • 20,795
  • 11
  • 69
  • 104
  • @user3652433 Continuing after following Andrey's suggestion of using functions, use a script to use/call these functions. – Divakar May 19 '14 at 13:04