Converting Menu to Listdlg

조회 수: 4 (최근 30일)
Sean St Cyr
Sean St Cyr 2020년 6월 28일
댓글: Sean St Cyr 2020년 6월 29일
%UserSelections
choice=listdlg('ListString',Name);
Power=CurData(1,:).*CurData(choice+1,:)*10^-3;%multiplying by 10^-3 to covert mA into A
fprintf('Voltage Choices:\n')%showing the choices
fprintf('%d\t\t',CurData(1,:))
fprintf('\n')
Volt = menu('Select a Voltage', num2cell(CurData(1, :)));
Voltage = CurData(1, Volt);
Current = CurData(choice+1, Volt);
Component = Name(choice);
fprintf('Component %s\n', string(Component));
fprintf(' \tVoltage = %d V \n', Voltage);
fprintf('\tCurrent = %.3f A\n',CurData(choice+1, Volt)*10^-3); %Converts mA to A
fprintf('\tPower = %.3f W\n',Power(Volt)); %Gives the first power answer instead of the string
I am trying to convert my coding from 'menu' to a 'listdlg' code, and I am trying to do it to my "Volt" string, I have a set of data that are numbers and trying to allow a dialouge box to pop up and have a person select it using listdlg.

채택된 답변

Cris LaPierre
Cris LaPierre 2020년 6월 28일
You can find examples in the documentation. You probably want something like this.
Volt = listdlg('ListString',string(CurData(1, :)),'Name','Select a Voltage');
  댓글 수: 1
Sean St Cyr
Sean St Cyr 2020년 6월 29일
Thank you so much that helped a ton

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by