How to make function assign variables that will stick around after the function is done running?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Solarmew
am 20 Mai 2015
Kommentiert: Star Strider
am 20 Mai 2015
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')
0 Kommentare
Akzeptierte Antwort
Star Strider
am 20 Mai 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
