select multiple checkboses in matlab - matlab

I have a gui with nine checkbox in the following code i can select only one of each but what i wanted to add is if the NormeEm checkbox is selected i want to select another checkbox, which i tried to set up at the end of the code by using a switch and 2 cases so that only another one checkbox can be selected but it won't show and it doesn't give me an error code.
function kgexec4n(Init)
%KGEXEC4N boite de dialogue "norme" associée à kgexec4
%CAVIAR2, © ALSTOM + OL 2000/04-2003/03
error(nargchk(0,1,nargin));
persistent blkParamNorm
%%%% ouverture boite
if nargin==1
%"full block path name" du bloc ParamNorme
blkParamNorm=gcb;
if ~strcmp(get_param(blkParamNorm,'MaskType'),'ParamNor')
errordlg(kverranorm(14),'Caviar3','modal')
return
end
%création figure
hf=kgui4n;
%en cas de librairie verrouillée on interdit OK
%x=get_param(get_param(gcs,'Parent'),'Lock'); %modif2.4 10/03/2006
rep=findstr(gcs,'/');
if isempty(rep)
active_sys=gcs;
else
active_sys=gcs(1:rep-1)
end
x=get_param(active_sys,'Lock')
set( findobj(hf,'Tag','NormeOK'), 'Enable', onoff(~onoff(x)) )
else
hf=gcbf;
end
%%%% handles des contrôles et dévalidation de tout
hrb=[findobj(hf,'Tag','Norme0')
findobj(hf,'Tag','Norme1022')
findobj(hf,'Tag','NormeEm')
findobj(hf,'Tag','NormeG53')
findobj(hf,'Tag','NormeCh')
findobj(hf,'Tag','NormeUsrV')
findobj(hf,'Tag','NormeUsrI')
findobj(hf,'Tag','Norme50160')
findobj(hf,'Tag','Norme519')];
hrbVal=get(hrb,'Value');
set(hrb,'Value',0)
hno=[findobj(hf,'Tag','Param0')
findobj(hf,'Tag','Param1022')
findobj(hf,'Tag','ParamEm')
findobj(hf,'Tag','ParamG53')
findobj(hf,'Tag','ParamCh')
findobj(hf,'Tag','ParamUsrV')
findobj(hf,'Tag','ParamUsrI')
findobj(hf,'Tag','Param50160')
findobj(hf,'Tag','Param519-1')
findobj(hf,'Tag','Param519-2')
findobj(hf,'Tag','Param519-3')
findobj(hf,'Tag','Param519-4')];
set(hno,'Enable','off')
%%%% gestion dynamique de la boite
switch get(gcbo,'Tag'); %l'objet ayant provoqué l'appel
%dialogue dynamique
case {'Norme0','Norme1022'}
set(gcbo,'Value',1)
case 'NormeEm'
set(gcbo,'Value',1),enable(hno(3))
switch get(gcbo,'Tag');
case 'Norme1022'
set(findobj(hf,'Tag','Norme1022'),'Value',1)
case 'NormeUsrV'
set(findobj(hf,'Tag','NormeUsrV'),'Value',1),enable(hno(6))
end
case 'NormeG53'
set(gcbo,'Value',1),enable(hno(4))
case 'NormeCh'
set(gcbo,'Value',1),enable(hno(5))
case 'NormeUsrV'
set(gcbo,'Value',1),enable(hno(6))
case 'NormeUsrI'
set(gcbo,'Value',1),enable(hno(7))
case 'Norme50160'
set(gcbo,'Value',1),enable(hno(8))
case {'Norme519','Param519-1'}
set(hrb(9),'Value',1),Scr519(hno(9:12))
end
If i could have some help to figure out what's wrong in my code it would help me a lot

Related

Get parameter of a specific Simulink Block and compare it, Matlab

I'm parsing a text file with matlab which looks like this :
[Date]
2019-03-27 10:45:10.167618
[Component]
Component_Name : Manager principal
Component_ID : _ocl_MEu9Eemg_bhrv2HEbw
{Port}
Port_Name : FOP 1
Port_ID : _sZMXoEu9Eemg_bhrv2HEbw
Port_Type : Outgoing Port
[Component]
Component_Name : Manager 2
Component_ID : _r-HlMEu9Eemg_bhrv2HEbw
{Port}
Port_Name : FIP 1
Port_ID : _sZWIoku9Eemg_bhrv2HEbw
Port_Type : Incoming Port
[Link]
Link_Name : On/Off
Link_ID : _sZfSkku9Eemg_bhrv2HEbw
Link_Source_Name : Manager principal
Link_Source_ID : _ocl_MEu9Eemg_bhrv2HEbw
Link_Source_Port_Name : FOP 1
Link_Source_Port_ID : _sZMXoEu9Eemg_bhrv2HEbw
Link_Target_Name : Manager 2
Link_Target_ID : _r-HlMEu9Eemg_bhrv2HEbw
Link_Target_Port_Name : FIP 1
Link_Target_Port_ID : _sZWIoku9Eemg_bhrv2HEbw
I create a systeme for each [Component] i find and in each systems i create an input or output if the [Component] is a Source or a Target of a [Link].
In my text file example : On/Off is a link between 'Manager principal' and 'Manager 2'. So in the first System (Manager principal) i have an output called On/Off with a specific tag in tag description i set and in the second system (Manager 2) an input called On/Off with a specific tag in the Block tag i set.
So when i launch my code i have 2 system with 1 block in each system.
In this 2 blocks, if it's about the same link (in this example it is) we have this tag :
#_sZMXoEu9Eemg_bhrv2HEbw ==> #_sZWIoku9Eemg_bhrv2HEbw
The ID of the source port ==> the ID of the target port
This is what distinguish a Link than an other.
The context is : if the user change only the name of the Link for example Off/On instead of On/Off it must not create a new block because it's the same Link. So i would like to make a findBlocks() and for each blocks in the current system, i would like to do : if both ID's in tag description are same than in the text file so we just update the name of the block for example .
Here is the code where i create my blocks :
Update : I success to recover C which is the string inside Block tag.
B = find_system(sprintf('%s', component_NameValue));
C = get_param(find_system(sprintf('%s/%s', component_NameValue, link_NameValue)), 'Tag');
if (compareOut == 1) && (compareSource == 1) % Si c'est un port sortant et que c'est le port source du link
add_block('simulink/Ports & Subsystems/In1',[component_NameValue '/' link_NameValue]); % alors on ajoute un block Output de même nom que le link dans le système du composant que l'on parse
linkDescription = sprintf('Link : \n\n%s ==> %s \n\nComposant : \n\nDe : %s (%s) \nVers : %s (%s) \n\nPort Source : \n\n%s \n%s \n\n', link_NameValue , link_IDValue , link_SourceNameValue , link_SourceIDValue, link_TargetNameValue , link_TargetIDValue, link_SourcePortNameValue, link_SourcePortIDValue);
linkTag = sprintf('#%s ==> #%s', link_SourcePortIDValue, link_TargetPortIDValue);
set_param(gcb, 'Tag', linkTag);
set_param(gcb,'Description',linkDescription); % On ajoute une description au block contenant les infos du lien en question contenus dans le fichier texte
end
if (compareIn == 1) && (compareTarget == 1) % Si c'est un port entrant et que c'est le port target du link
add_block('simulink/Ports & Subsystems/Out1',[component_NameValue '/' link_NameValue]); % alors on ajoute un block Input de même nom que le link dans le système du composant que l'on parse
linkDescription = sprintf('Link : \n\n%s ==> %s \n\nComposant : \n\nDe : %s (%s) \nVers : %s (%s) \n\nPort Target : \n\n%s \n#%s', link_NameValue , link_IDValue , link_SourceNameValue , link_SourceIDValue, link_TargetNameValue , link_TargetIDValue,link_TargetPortNameValue, link_TargetPortIDValue);
linkTag = sprintf('#%s ==> #%s', link_SourcePortIDValue, link_TargetPortIDValue); %On ajoute un # devant l'ID du port pour pouvoir le retrouver et voir si un port à été modifié/rajouté/supprimé
set_param(gcb, 'Tag', linkTag);
set_param(gcb,'Description',linkDescription); % On ajoute une description au block contenant les infos du lien en question contenus dans le fichier texte
end
Thanks for helping in advance

ControlGetText get from ClassNN to Number

ClassNN= TDBEditArpa16
I want AutoHotKey to get this value as a number and save it to an integer variable. How can I do this?
Note: I tried to do it through the following code, but the program can not identify it as a number.
ControlGetText, qtp1, TDBEditArpa16, Alteração de Produtos, Informações de Custo
StringTrimRight, qtp1, qtp1, 4
qtp1 = (%qtp1% + 2)
msgbox %qtp1%
Storing the result of an expression:
To assign a result to a variable, use the := operator.
ControlGetText, qtp1, TDBEditArpa16, Alteração de Produtos, Informações de Custo
StringTrimRight, qtp1, qtp1, 4
qtp1 := (qtp1 + 2)
msgbox %qtp1%
Variable names in an expression are not enclosed in percent signs

Event-B Rodin platform, Modelling Sub-Sets relation

I'm a beginner on Event-B and I'm trying to model a machine where the set PERSONNE includes the set CLIENT which includes the set RESIDENT... I've searched on Rodin's documentation but I haven't found anything...
Here is the context
context contexteHumain
sets PERSONNE CLIENT RESIDENT
axioms
#axm1; finite(PERSONNE)
#axm2; finite(CLIENT)
#axm3; finite(RESIDENT) // Definition of three possible sets
and here is the machine
machine machineFunKeyHotel sees contexteHumain
variables
pers
reserv
cli
resid
chkin
chkout
invariants
#inv1: pers ⊆ PERSONNE
#inv2: cli ⊆ CLIENT
#inv3: resid ⊆ RESIDENT
// Définis les 3 variables d'ensemble de Personnes, Clients et Résidents
#inv4: reserv ∈ BOOL
#inv5: chkin ∈ BOOL
#inv6: chkout ∈ BOOL
// Les paramètres booléens si la ⦂personne a réservé, check-in ou check-out.
#inv7: CLIENT ⊆ PERSONNE
#inv8: RESIDENT ⊆ CLIENT
// Et les relations entre les différnets ensembles d'humains·
events
event INITIALISATION
begin
#act1: reserv ≔ FALSE
#act2: chkin ≔ FALSE
#act3: chkout ≔ FALSE
// Ces valeurs sont à faux, en effet, au début personne n'a ni réservé ni check-in
// Encore moins check out.
#act4: resid ≔ ∅
#act5: cli ≔ ∅
// Au début le nombre de client et de résidents sont zéro
#act6: pers ≔ ∅ //???
// Définir un nombre de personne presqu'infini (Personnes sur terre estimé à
// 7 290 477 807 personnes le vendredi 3 avril 2015 à 9 h 07 min et 24 s (GTM +1)
end
event réserver
// Lorsqu'une personne quelconque a réservé ça implique quelle soit ajoutée
// à l'ensemble clients.
any potentiel_client
where
#gr1: potentiel_client ∈ PERSONNE
#gr2: reserv = TRUE
then
#act1: cli ≔ cli ∪ {potentiel_client}
end
event checkerin
// Lorsqu'un client a passé l'étape de check-in, cela implique qu'il est ajouté
// à l'ensemble résident
any futur_resident
where
#gr1: futur_resident ∈ CLIENT
#gr2: chkin = TRUE
then
#act1: resid ≔ resid ∪ {futur_resident}
end
event checkerout
// Lorsqu'un résident a procédé au check out cela implique qu'il est retiré
// et de l'ensemble client et de l'ensemble résident.
any resident_actuel
where
#gr1: resident_actuel ∈ RESIDENT
#gr2: chkout = TRUE
then
#act1: resid ≔ resid ∖ {resident_actuel}
#act2: cli ≔ cli ∖ {resident_actuel}
end
end
I think I've got the idea but I cannot manage how to solve the various errors I get:
Types CLIENT and PERSONNE do not match (3 times)
Types RESIDENT and CLIENT do not match (2 times)...
There is a problem in your specification that is very common for beginners in Event-B. :)
You have introduced three deferred sets PERSONNE, CLIENT and RESIDENT. But I think a client or a resident are persons, too. And all deferred sets are constants, so with this construction, you're not able to modify your set of clients or residents.
I think the basic problem is the keyword SETS. You do not have to specify all sets of your machine there. Think TYPES! You just introduce a new type (I think you need only PERSONNE here) and have a constant for all elements.
context contexteHumain
sets PERSONNE
So remove the sets CLIENT and RESIDENT. I would suggest to remove all axioms, too. Do you really have to assume that the set of possible persons is finite?
Adapt your invariants:
invariants
#inv1: pers ⊆ PERSONNE
#inv2: cli ⊆ pers
#inv3: resid ⊆ cli
Remove inv7 and inv8. You probably want to add an invariant that the set of persons in your system is finite (in contrast to all possible persons in PERSONNE):
#inv9: finite(pers)
Accordingly, you would adapt your guards:
#gr1: futur_resident ∈ cli
resp.
#gr1: resident_actuel ∈ res

MATLAB try and catch issue

I have a problem with the following try and catch code in MATLAB:
fonster='';
while ~(~isempty(fonster) && isnumeric(fonster) && isreal(fonster) && isfinite(fonster) && (fonster == fix(fonster)) && (fonster > 0))
try
fonster = input('Välj ett heltal till fönsterplatsen du vill lägga grafen i: ');
catch
disp('Du måste mata in ett heltal');
end
end
It never seems to enter the catch part of the code when entering an invalid input as a string to the input function. Instead it just runs the input all over again and ignores my output message. The wierd part is that I'm using a disp within a catch in another place in my code but this time it just doesn't work.
Here are some running examples:
Input without the try and catch statements:
Välj den fönsterplats du vill lägga grafen i: o
Error using input
Undefined function or variable 'o'.
Error in skapaPlot (line 11)
fonster = input('Välj den fönsterplats du vill lägga grafen i:
');
Error in mainMeny (line 17)
plot_handles = skapaPlot(plot_handles);
Välj den fönsterplats du vill lägga grafen i:
With try and catch:
Välj ett heltal till fönsterplatsen du vill lägga grafen i: f
Välj ett heltal till fönsterplatsen du vill lägga grafen i: d
Välj ett heltal till fönsterplatsen du vill lägga grafen i: s
Välj ett heltal till fönsterplatsen du vill lägga grafen i:
Why doesn't it display the disp part?!
Matlab's input expression evaluator will handle any exceptions raised during input, and immediately redisplay the prompt, and the exception will get cleared. So your catch handler never gets to see any exceptions. If you want to manage things yourself, use instead input(..., 's'), which returns the raw string. You can then perform your evaluation using 'eval()':
try
inputstring = input('Välj ett heltal till fönsterplatsen du vill lägga grafen i: ', 's');
fonster = eval(inputstring);
catch
disp('Du måste mata in ett heltal');
end

character error fortran 90

I'm struggling with a small program, I can't find how to correct one mistake.
My program:
program calcul
! ce programme permet d'effectuer des opérations mathématique de base
IMPLICIT NONE
REAL::x,y
character(len=1)::op
character(len=16)::op_msg
write(*,*)"entrer le type d'opération à effectuer(+,-,/,x,*)"
read(*,*)op
write(*,*)"entrer le premier nombre de l'opération"
read(*,*)x
write(*,*)"entrer le deuxième nombre de l'opération"
read(*,*)y
if(op=="+") then
write(*,*)x,"plus",y,"egale",x+y
else if(op=="-")then
write(*,*)x,"moin",y,"egale",x-y
else if ((op==("*").or.("x")) then
write(*,*)x,"multiplie par",y,"egale",x*y
else if (op=="/")then
write(*,*)x,"divise par",y,"egale",x/y
else
write(*,*)"erreur:operation incorrecte"
end if
end program calcul
The error message:
calculette.f90:21.26:
else if ((op==("*").or.("x")) then
1
Error: Invalid character in name at (1)
Any idea? I don't understand why "x" is an invalid character?
else if ((op==("*").or.op==("x")) then
You are evaluating two separate conditions, so each one needs a "left" and "right" side.