Put array in ListBox to choose different values for plot/ App Designer

Hi,
I want to put all these values in the array G into my ListBox, but it doesn't show up.
My array "zR" has different sizes.
My purpose for the ListBox is to choose a number and show in my plot different lines. I am also open to other solutions besides the ListBox for my purpose.
Thank you in advance !
app.ListBox.Items=num2str(zR)
app.ListBox.ItemsData=num2str(zR)

답변 (1개)

Hello,
No need to assign ItemsData. Try this
app.ListBox.Items=num2str(zR(:))

댓글 수: 4

Henry Tran
Henry Tran 2020년 12월 10일
편집: Henry Tran 2020년 12월 10일
Hello,
thank you for you answer, unfortunately I got this error.
"Error using matlab.ui.control.internal.model.AbstractStateComponent/set.Items (line 184)'Items' must be a 1-D cell array of character vectors or a string array."
Is there another solution ?
As mentioned in the error 'Items' must be a 1-D cell array of character vectors or a string array.
Try this
app.ListBox.Items = mat2cell(a(:), ones(size(a)), 1)
It appears an error after entering your suggestion:
"Error using matlab.ui.control.internal.model.AbstractStateComponent/set.Items (line 184)
'Items' must be a 1-D cell array of character vectors or a string array."
I figured the solution for my problem:
app.ListBox.Items = num2cell(num2str(zR),2)
Anyway thank you for your help !
Great that you've figured it out yourself!

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

카테고리

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

제품

릴리스

R2020a

질문:

2020년 12월 10일

댓글:

2020년 12월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by