assign a value to a variable inside if body and call it as a condition in another if statement

15 visualizzazioni (ultimi 30 giorni)
i define variables by using following commands
for i=1:4
syms H(i) G(i) D(i)
end
and values to thes variables inside body of if statement
for i=1:20
if .....
H(1)=1;
break
elseif
continue
else
H(1)=0;
end
end
now i call these variables in another if statement as a condition
if (H(1)==1) && (H(2)==1) && (H(3)==1) && (H(4)==1)
figure; imshow(B);
end
this code neither give error nor output. can someone tell me where i am wrong or why it does not give me output.
  2 Commenti
Stephen23
Stephen23 il 29 Giu 2019
Is there a particular reason why you need to use symbolic variables?
If yes, why not use the symbolic vector syntax shown in the documentation?:
Zubia Mansoor
Zubia Mansoor il 30 Giu 2019
No, particular reason. I needed to define a variable before using it in if statement. I also try H(i)=0; to initialize it but it still did not give me any output.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by