Hi, I know this is a very common question. I have searched about the issue in multiple places but couldn't find a proper solution to my problem specifically.
So, I have one FEM code that gives multiple outputs, such as:
function [KAPPA, STIFF, BASIS] = RunGMsFEM
Then, I have another function that simulates the FEM code (training number) m times,
function  = TrainData(fun, m, indices)
predefine some variables
for k = 1:m
[KAPPA, STIFF, BASIS] = fun;
save data as csv
The problem is that when I run the code:
[KAPPA, STIFF, BASIS] = RunGMsFEM
in command window I am not getting any error. But whenever I run the nested function
TrainData(RunGMsFEM, 100, some_indices)
I am getting too many output argument error on the exact same line:
[KAPPA, STIFF, BASIS] = fun
I know MATLAB doesn't let you assign multiple variables at one using vectors (like tuples in Python (a, b) = (3, 5)), and I understand the error but somehow it works perfectly when I run this code in command window. I tried to change my code into one output vector/matrix and then pull out he Z = [KAPPA, STIFF, BASIS] variables from the one output but the problem here all of the outputs have different size. For example: KAPPA is a vector, STIFF and BASIS are matrices with different sizes.
I can run the code in the command window but then I have to predefine all of the variables by hand which is annoying. Is there anyway to use a multiple output function inside another function?