IF-ELSE NOT FUNCTIONING PROPERLY

|So this is my code, for some reason instead of reading the 'if' statement and showing 'accept' it immediately skips to 'else' and show 'reject' as a result in my hypothesis test PLEASE I NEED HELP FOR THIS :( | if true
% code
endedit1 = str2num(get(handles.edit1,'string'));
text11 = num2str((20-edit1)/(1.3/sqrt(15)));
if text11 > -5.5 & text11 < 5.5
set (handles.text13,'string','accept');
else
set(handles.text13,'string','reject');
end
set(handles.text10,'string',edit1);
set(handles.text11,'string',text11);
if true
% code
end

Antworten (2)

Fangjun Jiang
Fangjun Jiang am 15 Nov. 2017

0 Stimmen

text11 = (20-edit1)/(1.3/sqrt(15));
Image Analyst
Image Analyst am 15 Nov. 2017

0 Stimmen

Why are you comparing a character string to a double? A string is NOT a number even if the characters in the string are numbers. Why not just use endedit1:
if endedit1 > -5.5 & endedit1 < 5.5

Produkte

Gefragt:

am 15 Nov. 2017

Beantwortet:

am 15 Nov. 2017

Community Treasure Hunt

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

Start Hunting!

Translated by