Borrar filtros
Borrar filtros

How to make function assign variables that will stick around after the function is done running?

1 visualización (últimos 30 días)
For example:
function test(x)
car.color = x;
end
if i first input
global car
I want car.color to exist after i input test('red')

Respuesta aceptada

Star Strider
Star Strider el 20 de Mayo de 2015
Have it return the structure ‘car’ as an output:
function car = test(x)
car.color = x;
end
%
car = test('red')
produces:
car =
color: 'red'
  8 comentarios

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by