-4

I have a function that goes something like this:

function [] = function1

-variable1= value1; -variable2= value2;

-matrix1=[] -matrix2=[]

-loops that fill in matrix1 and matrix2

-more declarations

-final function1 end

function2[] takes values from function 1 and does stuff, creates new variables funcion2 end

function3[] that uses values from function 2 and function4[] that uses function 3.

(Sorry for all of that by the way). Now, my question is, is there anyway to save variables, arrays, etc. in the workspace for later analysis? All 4 functions are on the same tab in the MATLAB editor.

3
  • What have you tried? Have you tried a google search on "Matlab save"? You can use save for saving either full workspace or selected variables. Sorry, but a simple google search would have solved the problem, so -1 Commented Jun 18, 2015 at 6:26
  • 1
    Don't save the variables, pass them through the functions (i.e. function [out1,out2,etc..] = function1(in1, in2, in3, etc...)). Also this is not a good way to ask a question, very hard to read. Rather make up simplified mock functions (i.e. a minimal working example) that demonstrates your issue. Commented Jun 18, 2015 at 7:31
  • possible duplicate of Using matlabs save in functions Commented Aug 26, 2015 at 14:00

1 Answer 1

-1

To save any particular variable from workspace in Matlab you should execute the following

save('Name of the mat file','Name of the variable')

To save multiple variable the command shall be

save('name of the mat file','var1','var2'...)

variable can be array, matrix, structure, double anything. For any other use of the function save please docsearch it in the command prompt

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.