How to plot graph the values of given program

1 Ansicht (letzte 30 Tage)
N M Channabasavayya
N M Channabasavayya am 1 Mai 2019
Kommentiert: Star Strider am 2 Mai 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

Akzeptierte Antwort

Star Strider
Star Strider am 1 Mai 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 Kommentare
N M Channabasavayya
N M Channabasavayya am 2 Mai 2019
Thank you sir.It worked.
Star Strider
Star Strider am 2 Mai 2019
As always, my pleasure.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by