MATLAB: Combining functions and commands in to one script

commandsfunctionnftoolscript

I have to provide a script that reads in values from 2 separate files. The script should also provide an output file for the predicted value, given the input data. So I have created 2 functions to read in the input files: flle1 and file2. I then have commands that I ran to combine the info in file1 and file2 so that the combined info from file1 and file2 can be input in to the nftool. I also have commands that I ran to modify file3 in order to use it as target data in the nftool. How do I combine this info (functions, commands, nftool data) in to one script so that I can then run this script such that another file1 and file2 can be provided to give an output file?

Best Answer

Functions by default don't show their scope variables in the workspace.
Did you have any error while running your code? If you don't, you can just perform a test by not using function in your 1st line.
So, just comment the first line of your code, and check if despx and despy appears in your workspace.
Then, your're performing the pipeline I mentioned before.
% Procedural code
% Here you call your functions
despx = importXfile('yourInput.csv')
despy = importYfile('youInput.csv')
% -------------------
%% Functions section
function x_2 = importXfile(filename, dataLines)
% function code

function y_2 = importYfile(filename, dataLines)
% function code