how do i store a variable out of my function?

9 visualizaciones (últimos 30 días)
tyler hollings
tyler hollings el 4 de Sept. de 2020
Comentada: tyler hollings el 4 de Sept. de 2020
i have a function file im calling in a script and when i try to assign its out put to a variable it says "Too many output arguments."
i know funtion works right i just dont know how to store it into a variable.
here is my function
function create_array(N,M,row_orient)
if row_orient==1
for i=1:N
for j=1:M
if N==M
x(i,j)= N*(i-1)+j
elseif M-N >=1 | N-M >= 1
x(i,j)=M*(i-1)+j
end
end
end
elseif row_orient==0
for i=1:N
for j=1:M
if N==M
x(j,i)= N*(i-1)+j
elseif M-N >=1 | N-M >= 1
x(j,i)=M*(i-1)+j
end
end
end
end
end
and here is the script im calling it to
x=create_array(3,1,1)

Respuesta aceptada

Asad (Mehrzad) Khoddam
Asad (Mehrzad) Khoddam el 4 de Sept. de 2020
The first line should be
function x = create_array(N,M,row_orient)
to return the generated matrix
  2 comentarios
tyler hollings
tyler hollings el 4 de Sept. de 2020
but thats what it is, its in the function file,
my function works in other scripts until i try to assign it to a variable.
for example
create_array(3,1,1) works
but
x=create_array(3,1,1) does not work
tyler hollings
tyler hollings el 4 de Sept. de 2020
never mind youre totally right hahaha thanks for the help

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by