can any one help me i wanna to correct this code ?

#
pih=[];
n=[]; % matrice contenant le nbr de tag n
i=[]; % matrice contenant le nbr des descendants
a=[];
b=[];
w=[];
tt=[];
s=19; % parametre du boucle max desz nbr n
p=5; % para max des nbr i
k=8; % taille de l'identifiant
m=2; % modulo
h=3 ; % niveau de l'arbre
for im=1:s
n=1:1:s;
end
g=prod(n); % le calcul du factoriel n
for is=1:p
i=1:1:p;
end
o=prod(i); % le calcul du factoriel i
x=g-o; % le calcul du factoriel n-i
f=g/(o*x); % le calcul du combinaison i parmi n
a= [a;2^(k-m*h)]; % maatrice contenant la valeur 2^(k-m*h)
gg=prod(a) / (o*prod(a)-o); % combinaison de i parmi a
b=[b;2^k]; % matrice contenant 2^k
cc= prod(b) / o * (b-o); % combinaison de i parmi b
nn=gg/cc; % la deuxiéme partie de l eq de pih
w=[w;((2^k)-(2^(k-(m*h))))]; % matrice contenant ((2^k)-(2^(k-(m*h))))
ww= prod(w)/ o* prod(w)-o; % combinaison de i parmi ww
ss=b-i;
rr=prod(b-i);
zz=rr/((g-o)*rr)-(g-o); % combinaison de (n-i) parmi ww
pih=[pih;f*zz*nn]; % valeur final de pih
kk=96;
bcmd=5;
bnvb=8;
v=[];
for m=1:5
if(m>=2)
v=[v;bcmd+bnvb+kk-m+2.^m]
elseif(m==1)
v=[v;bcmd+bnvb+kk]
end
end
pnd=[];
for ii=1:0.1:1
pnd=[pnd;1-sum(pih(ii))];
end
encyy=[];
for j=1:0.1:63
for h=1:0.1:3
n=2:2:16;
% if(n>=2)
encyy =[encyy;sum((sum( pnd(j))) ,h)+n];
end
alpha=40;
tt=[tt;((encyy*v)/alpha)] ;
end
nn=1:0.1:2;
plot(nn,tt,'r');
#
the error msg is :
plot(nn,tt,'r');
??? Error using ==> plot
Vectors must be the same lengths.

Answers (2)

Learn to debug. Type this at the command line:
dbstop if error
Then run your code. It will pause at the error and you will be able to examine the variables involved. Type this:
size(nn)
size(tt)
They will be different sizes. So look upstream in your code to figure out why they are different.
Try this:
nn = linspace(1,2, length(tt));
plot(nn, tt, 'r*-');

2 Comments

plot(nn, tt, 'r*-'); ??? Error using ==> plot Vectors must be the same lengths. :(
That can't be. Look at my linspace function. I told it to make nn exactly the same number of elements as tt. What does this say
whos nn
whos tt
By the way, give us code that produces the error that you have. When we copy and paste it, it gives some totally different error.

Sign in to comment.

Tags

No tags entered yet.

Asked:

on 1 May 2015

Edited:

on 1 May 2015

Community Treasure Hunt

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

Start Hunting!