How I can storage data for arrays
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi! I can create an array with down but when i call the script again and add new values, previous values is deleting how i can storage array ?
thisname = input('Enter the name', 's');
thisnumber = input('Enter the phone number','s');
thisaddress = input('Enter the address','s');
PHONE.name = thisname; PHONE.number = thisnumber; PHONE.address = thisaddress;
0 Kommentare
Akzeptierte Antwort
Oleg Komarov
am 24 Mai 2012
An example with 2 entries (change n to increase the number of entries):
n = 2
for ii = 1:n
Phone(ii).name = input('Enter the name: ', 's');
Phone(ii).number = input('Enter the phone number: ','s');
Phone(ii).address = input('Enter the address: ','s');
end
I am indexing the structure Phone where ii = 1,2,...
You can apply this syntax to your case w/o using the loop.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Setup and Configuration 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!