Read a vector from Excel and use it in several functions in a code
Info
This question is closed. Reopen it to edit or answer.
Show older comments
Hi!
I know how to read the data from excel, but I dont know how to make it "visible" for several functions in my Mathlab code. If I read the vector directly into the functions, it takes to much of times.
Can please some help how to do?
Regards Joachim
1 Comment
Dennis
on 14 Aug 2018
Pass them as input to the function:
vector=1:5;
MyFcn(vector);
function MyFcn(vector)
disp(vector)
end
Answers (1)
Pass the data as input arguments. This is explained well in the MATLAB documentation:
- How to define functions with input arguments is clearly explained in the function help.
- How to call functions with input/output arguments is shown in the introductory tutorials: https://www.mathworks.com/help/matlab/getting-started-with-matlab.html
- The documentation clearly states that the best practice for passing data between workspaces, such as to/from a function, is to use input/output arguments: https://www.mathworks.com/help/matlab/matlab_prog/share-data-between-workspaces.html
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!