MATLAB Answers


It shows Error in my GUI...

Asked by Lalit Patil on 21 Feb 2013
 Error= num2str(err)
if Error(1) > 0.10000
    L = 'Fail.';
    L = 'Pass';

This is my program -

First In command window i am getting this answer in two lines and i want to use second, but every time it will not give two answers, but whatever the number is, i want to use last,

 Error =
 0.091683    0.085897

But in GUI it always shows Fail.. Why..?




No products are associated with this question.

1 Answer

Answer by Walter Roberson
on 21 Feb 2013

You are converting "err" to a string, and then comparing the string to the numeric value 0.10000. Why are you not comparing err instead of Error?


Yes it works for me.. Now how to deal with last value.?

That doesn't make sense. What Walter asked is why you don't simply do this:

if err(2) > 0.10000
    L = 'Failed';
    L = 'Passed';

If i tale only

 err > 0.10000

then it takes first value of err and then works correctly, but

Currently i know in answer of err that there are two values so i can take

 err(2) > 0.10000

But each time i will not know. Some time there will be 3 values or some time there will be 4.. So, i want to do such that whatever the number of values, i have only to take last..

So, i may have to apply any counting mechanism or any thing else and how..?

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!