Store text in array as string from GUI text box

On the first screen of my GUIDE-made GUI I want the participant to enter their name in the text-box and press the OK push button. Once they press the button, the name should be stored in the 1st column, 2nd row of an array for the participant's data in the form of a string. How may I do this?
N.B. Prior to the opening of this GUI, I already have an array for the participant's data created with multiple columns and 2 rows, where the first row is filled (header), and the 2nd rows are empty (to be filled with participant data).
Help would be much appreciated.

 채택된 답변

Image Analyst
Image Analyst 2014년 12월 15일
편집: Image Analyst 2014년 12월 15일

0 개 추천

What is your array? Is it a cell array, or a table? Let's say it's a cell array, then just get the edit field and assign it to whatever column you want
editString = get(handles.edit1, 'String');
ca{2, columnNumber} = editString;
Or if it's a table
rowToChange = 2; % Whatever....
% Change value in row 2 of column called "Col8". t is the table variable.
t.Col8{rowToChange} = editString;

댓글 수: 3

Muaaman
Muaaman 2014년 12월 15일
편집: Muaaman 2014년 12월 15일
What would be the best option to choose (array/table/something else) if I have to set it up like this:
The first column are all String headers (e.g. Name | Score | Total (the vertical columns were just for illustrative purposes that they're seperate columns)).
Then the subsequent row(s) are all numerical values, no wait..
CORRECTION: My apologies, the second row first column has String (the participant's name). All other cells in the second row are numerical.
Thank you for your reply.
If all rows in each column are of the same type (string, number), then use a table. If any column will have a mix of data types in the column (e.g. string and number both are in column 1) then use a cell array. For a table, all values in a column are the same data type, though the column header is a string/word/label for that column.
Muaaman
Muaaman 2014년 12월 15일
Thank you very much Image Analyst.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Tables에 대해 자세히 알아보기

질문:

2014년 12월 15일

댓글:

2014년 12월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by