Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Hello, so far I can't get this to respond correctly
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Clc;
Clear all;
r1=randperm(2,1);
r2=randperm(2,1);
a=sort(r1);
b=sort(r2);
x=[a,b]
q=[2,1]
If x~=q
Disp(X). %cannot get it to correctly display the numbers of the variable every time it doesn't equal q
Else
Disp('x is equal to q')
End
2 comentarios
John BG
el 8 de Ag. de 2016
why do you sort a scalar anyway?
r1 and r2 are coin tosses, they are either 'head' or 'tail'
and instead of
r1=randperm(2,1);
r2=randperm(2,1);
why not just
x=randperm(2,2);
Walter Roberson
el 8 de Ag. de 2016
Using two separate randperm is selection with replacement. Using one randperm would be selection without replacement.
For selection with replacement you could use randi()
Respuestas (1)
Azzi Abdelmalek
el 7 de Ag. de 2016
Editada: Azzi Abdelmalek
el 7 de Ag. de 2016
Don't use uppercase for Matlab function, It's not Clc but clc and not If but if
clc;
clear
r1=randperm(2,1);
r2=randperm(2,1);
A=sort(r1);
B=sort(r2);
X=[A,B]
q=[2,1]
if X~=q
disp(X) %cannot get it to correctly display the numbers of the variable every time it doesn't equal q
else
Disp('x is equal to q')
end
10 comentarios
Azzi Abdelmalek
el 7 de Ag. de 2016
clc;
r1=randperm(2,1)
r2=randperm(2,1)
X=[r1,r2];
q=[2,1];
if ~isequal(X,q)
disp(X) %cannot get it to correctly display the numbers of the variable every time it doesn't equal q
else
disp('x is equal to q')
end
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!