How can you initialize user input inside of a constructor?
Ältere Kommentare anzeigen
Example I want the x value to user input but i'm not sure how to get it to work
classdef name
properties
getName = input("Whats your name")
end
methods
function obj = name(x)
getName = x
end
end
end
2 Kommentare
Walter Roberson
am 3 Apr. 2019
Very odd. I was positive that someone had asked a question about constructors and input() just a short time ago, and that someone (Stephen perhaps) responded with a nice analysis of good reasons why that should never be done. But I can't seem to find that question now..
I wonder if someone did not like the response they received and deleted the question...
Rena Berman
am 4 Apr. 2019
(Answers Dev) Restored edit
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Functions finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!