How can I convert this script into a MATLAB function?
clear all;
set={AB02XY_1,ZT99ER_1,UI87GP_1};
fileData1 = load([fileString set{1} '.mat']);
fileData2 = load([fileString set{2} '.mat']);
fileData3 = load([fileString set{3} '.mat']);
[A,B] = myfunction1_1(fileData1,fileData2,fileData3);
fileName = 'C:\Users\Documents\MATLAB\matrice_AAA001.mat';
save(fileName,'A','B');
clear all;
set={AB02XY_2,ZT99ER_2,UI87GP_2};
fileData1 = load([fileString set{1} '.mat']);
fileData2 = load([fileString set{2} '.mat']);
fileData3 = load([fileString set{3} '.mat']);
fileData4 = load('C:\Users\Documents\MATLAB\matrice_AAA001.mat');
[A,B] = myfunction1_2(fileData1,fileData2,fileData3,fileData4);
fileName = 'C:\Users\Documents\MATLAB\matrice_AAA001.mat';
save(fileName,'A','B');
I do processing on large data files, then to avoid the error ‘out of memory ‘, I split each file into two parts and I use at the beginning of each stage ‘clear all’. So, what I want is to have a function as AAA001 = function (AB02XY, ZT99ER, UI87GP, MyFunction1).
my problem is that I have to write the same script for other data files. So, is there a way to build a function where I can just change the file names AB02XY, ZT99ER, UI87GP, and the name of the function used ‘MyFunction1’ for the sub-processing to get on the last step the file AAA001.
NB: I simplified my script, but actually I divide each file into 5 parts. So I want to transform the 5 parts of my script in a single function!!!
Thank you for your help.
Here’s one way to do this. Call the function
Note that I assume that you want 5 file parts