While running my code through a GUI the SWITCH function does that detect the cases, or maybe it just jumps to the bottom otherwise every time.
contents = cellstr(get(S.element,'String'));t1 = contents{get(S.element,'Value')};t = char(t1);contents = cellstr(get(S.mass,'String'));u1 = contents{get(S.mass,'Value')};u = char(u1);contents = cellstr(get(S.volume,'String'));v1 = contents{get(S.volume,'Value')};v = char(v1);global dens switch t case strcmp(t,'Scandium') dens = 2.989; case strcmp(t,'Yttrium') dens = 4.469; case strcmp(t,'Selenium') dens = 4.809; case strcmp(t,'Krypton') dens = .003733; case strcmp(t,'Neodymium') dens = 7.007; case strcmp(t,'Antimony') dens = 6.685; case strcmp(t,'Astatine') dens = 7; otherwise dens = 8.55;end
Every time it jumps to the other wise option of — dens = 8.55.
Best Answer