How could I show a text if it's gave in number and I want to show it as a text?

2 visualizzazioni (ultimi 30 giorni)
I'm making a GUI; the user input a values and the main program output a number given those inputs but I don't to show the output-number, instead I want to show it as some linguistic. here is the code:
%%Those takes the inputs from a textbox and converts to double
Risk1=str2double(get(handles.Riesgo1,'String'));
Risk2=str2double(get(handles.Riesgo2,'String'));
Risk3=str2double(get(handles.Riesgo3,'String'));
Risk4=str2double(get(handles.Riesgo4,'String'));
Risk5=str2double(get(handles.Riesgo5,'String'));
%%This resolves an evaluation in the main program and hold it in 'momentocorrecto'
momentocorrecto=evalfis([Risk1 Risk2 Risk3 Risk4 Risk5],readfis('TG2'));
%%this put the number 'momentocorrecto' and sets in other textbox
set(handles.MomentoCorrecto,'String',momentocorrecto);
my solution was using if-elsif:
if 7<=momentocorrecto<=9
set(handles.MomentoCorrecto,'String','Elevado');
elseif 5<=momentocorrecto<7
set(handles.MomentoCorrecto,'String','Alto');
elseif 3<=momentocorrecto<5
set(handles.MomentoCorrecto,'String','Medio');
elseif 0<=momentocorrecto<3
set(handles.MomentoCorrecto,'String','Bajo');
else
set(handles.MomentoCorrecto,'String','');
end
At first it gaves me 'Elevado', but when I switch the inputs it keeps showing 'Elevado' and that's a mistake. I tried also with switch-case, doesn't work!! Thanks for your help

Risposte (1)

Muhammad Usman Saleem
Muhammad Usman Saleem il 18 Giu 2016
use
str(value)
to make string of no

Categorie

Scopri di più su Text Analytics Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by