Syntax for work space output and multiple variables to work space

Hi, I am trying to run a program and output more than one variable. Not sure on the syntax, but here is what I am going for:
function [Project, Counter] = NumberCycle(num,times2run)
(code)
end
I would like Mat lab to output the Project variable as one matrix in the work space and the Counter variable as a completely separate matrix in the work space. That way I could click on either variable when I need to look at them.
Lastly, when you send a variable to the work space, mat lab spits out that information in the command window as well (even if suppressed in the code), is there a way to stop that?
Any help is appreciated, thanks!

 Respuesta aceptada

‘I would like Mat lab to output the Project variable as one matrix in the work space and the Counter variable as a completely separate matrix in the work space.’
Call your function from your script file as:
[Project, Counter] = NumberCycle(num,times2run);
‘Lastly, when you send a variable to the work space, mat lab spits out that information in the command window as well (even if suppressed in the code), is there a way to stop that?’
If I understand correctly, put a semicolon ‘;’ at the end of the line calling your function (as I did here).

6 comentarios

Sorry for the late reply, but what you do you mean by 'call your function from the script file' ? Also, I tried [Project, Counter] with the semi-colon at the end, code still runs, but only outputting the Project variable.
Call it from your script as I described, but without the semicolon and see what the result is. I am assuming here that your function is creating variables named (in the function) ‘Project’ and ‘Counter’.
I also assume you’re calling your function from a script, which is a set of MATLAB assignments and function calls that is not itself a function. See Scripts, and particualrly Create Scripts, for details.
You can call it from the Command Window if you want, but that makes life more difficult. It’s much easier from a script.
Ok thanks, I found how to manage the script file, but the output is still only sending one variable to the work space.
Like you interpreted, Counter and Project are two separate variables, yet the script only outputs one of them (first one in the brackets) to work space.
Without seeing the code for your function, there is no way I can determine what the problem may be.
If the ‘first one’ is in brackets, check to see if it might be both outputs.
Yeah, not really sure to be honest. I will mess with the code a little more later on. Thanks for your help so far and with the suggestion using script files.
My pleasure.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Preguntada:

el 19 de Mzo. de 2016

Comentada:

el 24 de Mzo. de 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by