How to call and also return a matrix in a function?
Mostra commenti meno recenti
I have a certain requirement in my code that I need to define a separate function for computation of a variable. The variable is a matrix of order of 32x32. As inputs to the function, there are two different matrices of the same order. After calling the function in the code, I want the function to return the whole matrix of order 32x32.
This is how I am writing it currently (but it is not correct):
-calling the function :
matrix = variable(input1, input2);
where 'matrix' is the output and 'variable' is the function name. 'input1' and 'input2' are also matrices of order 32x32.
-function:
function output = variable(in1, in2)
I wanted to know the correct method to do this.
The error that I am getting:
Output argument "output" (and maybe others) not assigned during call to "variable".
Error in test (line 108)
matrix = variable(input1, input2);
3 Commenti
Kaushik Lakshminarasimhan
il 10 Dic 2017
What error are you getting?
Stephen23
il 11 Dic 2017
"This is how I am writing it currently (but it is not correct)"
"I wanted to know the correct method to do this."
What you have shown us is correct. If you are getting any error message then please show us the complete error message (this means all of the red text).
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Operators and Elementary Operations in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!