I am new at this. I've created a function script with 2 inputs and 2 outputs but when I run it only the answer to the first input/output pair is returned. Why doesnt the second output run?

 Respuesta aceptada

Image Analyst
Image Analyst el 25 de Mayo de 2019

0 votos

How did you call it? Did you accept both into variables? Like
[ouput1, output2] = MyFunction(input1, input2)

4 comentarios

Image Analyst
Image Analyst el 25 de Mayo de 2019
Kenneth's "Answer" moved here since it's not an actual answer to the original question:
in fact I did, preceeded by the word function [output1, output2]=myfunction(input1, input2) as you state.
Image Analyst
Image Analyst el 25 de Mayo de 2019
No, when you precede it with the word function, like
function [output1, output2]=myfunction(input1, input2)
that is where you define the function - say what it does. It doesn't actually call the function. You have to assign inputs and then call it without the word function, like
a=1;
b=2;
[c, d] = myfunction(a, b)
Kenneth Weintraub
Kenneth Weintraub el 25 de Mayo de 2019
that worked thanks!!!
Image Analyst
Image Analyst el 26 de Mayo de 2019
Can you please "Accept this Answer" then? Thanks in advance.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB en Centro de ayuda y File Exchange.

Productos

Versión

R2019a

Etiquetas

Preguntada:

el 25 de Mayo de 2019

Comentada:

el 26 de Mayo de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by