What does "if 1 ..." means? When is the if condition applied? What does that "1" mean?

So I'm analyzing a code. And there is this if condition : "if 1 ...". I don't understand when this condition is applied? What does the "if 1" mean?

Answers (1)

if 1 means nothing here
Maybe
if a==1
disp('yes')
end

5 Comments

The above explains when a variable a equal to 1 then yes will be displayed because the condition is satisfied.
There's this code in the program.
if 1
dx=sum(abs(x))*1e-5; f0=f(x);
for i=1:n
x1=x;x1(i)=x1(i)+dx; f1=f(x1); A(:,i)=(f1-f0)/dx;
end
else,
A=eye(n)*11;
end
I don't understand when is the "if" portion applied and when does the "else" occur? On what condition?
The programmer just set the condition to 1 to make sure the first block of code gets executed.
Hopefully it was just a temporary thing otherwise the whole if/else is not even needed.
Thank you sir Image Analyst , as he already mentioned it’s not even needed in this case

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Products

Release

R2018b

Asked:

on 28 Oct 2018

Edited:

on 28 Oct 2018

Community Treasure Hunt

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

Start Hunting!