I am interested in running a function that will plot a few different variables against eachother depending on which ones I input as the function input. However, these variables are the outputs of another function, or rather they are defined later in the function, AFTER I say they are the ones that I want to plot. In the past, I have ran the first function to put the variables in the 'base' workspace, then ran the second function which uses those variables.
The first fucntion looks like this (I've changed names to make it simpler to understand):
function [array_xldata] = grab_xldata ()
table_xldata = readtable('xl_sheet.xlsx','Sheet',1,'Range','K1:K18');
array_xldata = table2array(table_xldata);
And then the second function would use that variable, array_xl_data, as an input, pulling it from the workspace. I want to not use the workspace like this, and instead be able to keep it nice and tidy, and not have to run two seperate functions because at that point I should just combine them into one function. If I do not run the first function first in order to grab the data and put it into the workspace, when I enter the variable array_xl_data as the input of the second function, it says that the variable is undefined. So, I tried making the second function call on the first function BEFORE it tries to use the variable from the first function.
The second function looks like this (I've changed names to make it simpler to understand):
function  = sortandplot(x_name)
x_name = array_xldata;
x_sorted = sortrows(x_name);
This is supposed to run the first function, which will collect the data and publish it to the workspace as the variable array_xldata, and then pull that data from the workspace and use it in the function. But it isn't working, and just says the function array_xldata is undefined, even though it will be defined (or so I think) if the code would run that first function before doing anything else.
Is there any way to accomplish this, am I on the right track if so, and if not how should I be thinking of accomplishing this instead?
Also I'm fairly new to MatLab, sorry in advance!