How to plot graph the values of given program

1 visualización (últimos 30 días)
N M Channabasavayya
N M Channabasavayya el 1 de Mayo de 2019
Comentada: Star Strider el 2 de Mayo de 2019
I have this program and after running I ll get the values.
Now I need to plot all the values.
how to to that?
Help me.
Thank you
clc;
clear all;
A= [0 1 0 1 1 1 0 0
1 0 1 1 0 0 0 0
0 0 1 1 1 1 0 0
1 0 0 1 1 0 1 0
1 0 0 1 1 0 0 0
0 1 0 1 0 1 0 0
0 1 1 0 0 1 1 0
1 0 0 1 0 1 0 0] ;
N=64;
for n=0:(N-1);
B= circshift(A,n);
N = 64;
C= A==B ;
a=sum(C(C==1));
d= N-a;
R=zeros(n,1);
R=(a-d)/N;
disp(R);
end

Respuesta aceptada

Star Strider
Star Strider el 1 de Mayo de 2019
Try this:
A= [0 1 0 1 1 1 0 0
1 0 1 1 0 0 0 0
0 0 1 1 1 1 0 0
1 0 0 1 1 0 1 0
1 0 0 1 1 0 0 0
0 1 0 1 0 1 0 0
0 1 1 0 0 1 1 0
1 0 0 1 0 1 0 0] ;
N=64;
nv = 0:(N-1);
R = zeros(size(nv));
for n=1:numel(nv)
B= circshift(A,nv(n));
N = 64;
C= A==B ;
a=sum(C(C==1));
d= N-a;
R(n) = (a-d)/N;
% disp(R);
end
figure
plot(nv, R)
grid
How to plot graph the values of given program - 2019 05 01.png
  2 comentarios
N M Channabasavayya
N M Channabasavayya el 2 de Mayo de 2019
Thank you sir.It worked.
Star Strider
Star Strider el 2 de Mayo de 2019
As always, my pleasure.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by