Hi, I'm currently doing an assignment with Matlab functions and am having some trouble getting started. When I run this script, it does not return an error, but the 13x2 matrix loaded from the file is not saved as x. Instead, it seems to be stored as "ans". I need to use this variable to find the mean value and standard deviation in another function (with both functions being called in a "main" file). However, it always returns the error that the variable "x" is undefined. This problem persists regardless of whether I type, for example, "mean_value = mean(x)" or "mean_value = mean(ans)", leading me to believe that no variable is being stored at all.
The code is as follows:
function [x] = load_data
load_data = input('Which data file would you like to analyze? ', 's');
while exist(load_data) ~= 2
load_data = input('Please input a valid file name. ', 's');
[x] = load(load_data);
And the code for the analysis of the data is:
function [mean_value,std_dev] = analysis(data)
mean_value = mean(data);
std_dev = std(data);
disp(['The mean of the data is ', num2str(mean_value)]);
disp(['The standard deviation of the data is ', num2str(std_dev)]);
Like I said, both of these functions are being called upon in a separate file, which looks like this:
add_header ((not relevant to problem))
I also get the error "Not enough input arguments" depending on how I fiddle around with the code. The solution is probably something basic I'm just not getting, but any help would be appreciated.