tableData = get(handles.uitable1, 'Data')
tableData =
'99' [41]
'77' [13]
can i convert it to a normal matrix so i can do a function on it

댓글 수: 5

Have you tried table2array?
Guillaume
Guillaume 2018년 2월 21일
table2array has nothing to do with uitable. It certainly won't know what to do with a cell array.
If I understood the code correctly:
tableData % returns a cell
Having recreated this cell, array2table seem to covert the cell to the table:
a = {'99' '77'} % cell
b = [41 13] % double
b = num2cell(b) % double to cell
tableData = [a' b'] % cell concatenation
t = array2table(tableData) % cell to table
The output:
t =
2×2 table
tableData1 tableData2
__________ __________
'99' [41]
'77' [13]
However, like you said, it doesn't make any sense to have the number stored as a char in the first place.
Do you want the '99' to be converted to numeric so that you end up with a purely numeric array?
Amjad Green
Amjad Green 2018년 2월 21일
yes,the user inputs a matrix and i want to save in a matrix A so i can do my functions on it

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

 채택된 답변

Guillaume
Guillaume 2018년 2월 21일
편집: Guillaume 2018년 2월 21일

0 개 추천

Your uitable returns a cell array because you've defined the first column as char. If your uitable is supposed to contain numbers only then the easiest way to fix your problem, is to change the ColumnFormat of that first column to 'numeric'. If you show us the line(s) where you create that uitable we can give you the exact syntax.
Alternatively, it can be fixed after the fact, but it'll be slower and kind of pointless:
tableData = get(handles.uitable1, 'Data');
tableData = [str2double(tableData(:, 1)), cell2mat(tableData(:, 2))];

추가 답변 (0개)

카테고리

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

태그

질문:

2018년 2월 20일

댓글:

2018년 2월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by