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

3 views (last 30 days)
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')

Accepted Answer

Star Strider
Star Strider on 20 May 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 Comments

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!