انجمن سایت کلیدستان



اعلام خطا در فراخوانی درایه از ماتریسزمان کنونی: ۱۳۹۵/۰۹/۱۹، ۰۲:۰۸ ب.ظ
کاربران در حال بازدید این موضوع: 1 مهمان
نویسنده: jojolabger
آخرین ارسال: sbh400
پاسخ 5
بازدید 561

رتبه موضوع:
  • 0 رای - 0 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
اعلام خطا در فراخوانی درایه از ماتریس

اعلام خطا در فراخوانی درایه از ماتریس

#1
پس از نوشتن برنامه ماتریسی 1 در 23، به صورت زیر:


min_j=4;  %s
max_j=13;
min_jj=14; %u
max_jj=23;

Q=[di1,di2,di3,es1,es2,es3,es4,es5,es6,es7,es8,es9,es10,yu1,yu2,yu3,yu4,yu5,yu6,yu7,yu8,yu9,yu10];  % javabe dastgah yekja(di1,.. ra matrice bordar midahad)
%Q=double(Q)       har satre Q yek daste javab
[aa,bb]=size(Q);   %aa=tedade javab

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% for 'S'
 
for j=min_j:1:max_j  
for p=aa:-1:1 
                p;
                oo=j;
                Q(p,oo);
                if (Q(p,oo))<0
                Q(p,Smile=[];  % agar s(s^2) manfi delete
                M=M+1;
                end
end
Q;
[aa,bb]=size(Q);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% for 'U'
for jj=min_jj:1:max_jj
for p=aa:-1:1
                p;
                oo=jj;
                if Q(p,oo)<0 % agar U manfi delete
                Q(p,Smile=[];
                M=M+1;
                end
end
[aa,bb]=size(Q);
end
Q;

d1=Q(1,1);  %Q yek satri shode(yek javab baghi mande:javabe KT)
d2=Q(1,2);
d3=Q(1,3);

 d_charkhe=[d1' d2' d3'];
u1=Q(1,14);
u2=Q(1,15);
u3=Q(1,16);
u4=Q(1,17);
u5=Q(1,18);
u6=Q(1,19);
u7=Q(1,20);
u8=Q(1,21);
u9=Q(1,22);
u10=Q(1,23);

 
s_charkhe=[s1' s2' s3' s4' s5' s6' s7' s8' s9' s10']; 
u_charkhe=[u1' u2' u3' u4' u5' u6' u7' u8' u9' u10'];


و پس از اجرای برنامه بجای فراخوانی درایه مربوطه از ماتریس، با پیغام خطای زیر مواجه می شوم. به نظرتان اشکال کار از کجاست؟
پاسخ

اعلام خطا در فراخوانی درایه از ماتریس

#2
(۱۳۹۵/۰۱/۲۸, ۰۲:۱۸ ق.ظ)jojolabger نوشته: پس از نوشتن برنامه ماتریسی 1 در 23، به صورت زیر:


min_j=4;  %s
max_j=13;
min_jj=14; %u
max_jj=23;

Q=[di1,di2,di3,es1,es2,es3,es4,es5,es6,es7,es8,es9,es10,yu1,yu2,yu3,yu4,yu5,yu6,yu7,yu8,yu9,yu10];  % javabe dastgah yekja(di1,.. ra matrice bordar midahad)
%Q=double(Q)       har satre Q yek daste javab
[aa,bb]=size(Q);   %aa=tedade javab

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% for 'S'
 
for j=min_j:1:max_j  
for p=aa:-1:1 
                p;
                oo=j;
                Q(p,oo);
                if (Q(p,oo))<0
                Q(p,Smile=[];  % agar s(s^2) manfi delete
                M=M+1;
                end
end
Q;
[aa,bb]=size(Q);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% for 'U'
for jj=min_jj:1:max_jj
for p=aa:-1:1
                p;
                oo=jj;
                if Q(p,oo)<0 % agar U manfi delete
                Q(p,Smile=[];
                M=M+1;
                end
end
[aa,bb]=size(Q);
end
Q;

d1=Q(1,1);  %Q yek satri shode(yek javab baghi mande:javabe KT)
d2=Q(1,2);
d3=Q(1,3);

 d_charkhe=[d1' d2' d3'];
u1=Q(1,14);
u2=Q(1,15);
u3=Q(1,16);
u4=Q(1,17);
u5=Q(1,18);
u6=Q(1,19);
u7=Q(1,20);
u8=Q(1,21);
u9=Q(1,22);
u10=Q(1,23);

 
s_charkhe=[s1' s2' s3' s4' s5' s6' s7' s8' s9' s10']; 
u_charkhe=[u1' u2' u3' u4' u5' u6' u7' u8' u9' u10'];


و پس از اجرای برنامه بجای فراخوانی درایه مربوطه از ماتریس، با پیغام خطای زیر مواجه می شوم. به نظرتان اشکال کار از کجاست؟

سلام
دوست عزیز بنظر میاد برنامه نصفه کپی شده، تو همین برنامه چندتا پرانتز بسته نشده و نیاز داره پرانتزو ببندید. در ادامه اخطار میده di1 ندارید این هم نشانگر اینه که شما برنامه رو ناقص کپی کردید که ما نمی تونیم بهتون کمک کنیم. باید برنامه کامل باشه تا بتونیم در رفع خطا به شما کمک کنیم.
موفق باشید
rezavalizadeh95@gmail.com
پاسخ

اعلام خطا در فراخوانی درایه از ماتریس

#3
کل متن برنامه زیاده، ولی من کاملشو میذارم:
بعد از اجرا ارور خاصی میده که متوجه نمیشم چرا؟!
Attempted to access Q(1,1); index out of bounds because size(Q)=[0,23].

Error in plba (line 474)

متن کامل برنامه:

function plba

clear all
syms x1 x2 x3 R Rk
f=@(x1,x2,x3)(x2*x1^2*(x3+2));
g_1=@(x1,x2,x3)(-(x2^3*x3/71857*x1^4)+1);
g_2=@(x1,x2,x3)((x2*(4*x2-x1)*(12566*x1^3*(x2-x1))+2.46/12566*x1^2)-1);
g_3=@(x1,x2,x3)(-(140.534*x1^1)/(x2^1*x3)-1);
g_4=@(x1,x2,x3)(((x2+x3)/1.5)-1);
g_5=@(x1,x2,x3)(-x1+0.05);
g_6=@(x1,x2,x3)(x1-0.2);
g_7=@(x1,x2,x3)(-x2+0.25);
g_8=@(x1,x2,x3)(x2-1.3);
g_9=@(x1,x2,x3)(-x3+2);
g_10=@(x1,x2,x3)(x3-15);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f_x1=2*x1*x2*(x3+2);
f_x2=x1^2*(x3+2);
f_x3=x1^2*x2;

gradf=[f_x1,f_x2,f_x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_9=[g9_x1,g9_x2,g9_x3];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
g10_x1=0;
g10_x2=0;
g10_x3=1;


gradg_10=[g10_x1,g10_x2,g10_x3];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TT=10;
% <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
x1=0.1;x2=1;x3=10;gamma=0.25;epsilon1=0.01;epsilon2=0.01;

% <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

ch=0;
while TT>0
ch=ch+1;

Rk=R;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if ch==1
H=[1 0 0 ;0 1 0 ;0 0 1 ];

else
S=t_n*[d1;d2;d3];
Z=H*S;
x1=WE1;
x2=WE2;
x3=WE3;


KI=transpose([f_x1,f_x2,f_x3])+...
u1*transpose([g1_x1,g1_x2,g1_x3])+...
u2*transpose([g2_x1,g2_x2,g2_x3])+...
u3*transpose([g3_x1,g3_x2,g3_x3])+...
u4*transpose([g4_x1,g4_x2,g4_x3])+...
u5*transpose([g5_x1,g5_x2,g5_x3])+...
u6*transpose([g6_x1,g6_x2,g6_x3])+...
u7*transpose([g7_x1,g7_x2,g7_x3])+...
u8*transpose([g8_x1,g8_x2,g8_x3])+...
u9*transpose([g9_x1,g9_x2,g9_x3])+...
u10*transpose([g10_x1,g10_x2,g10_x3]);

x1=WEE1;
x2=WEE2;
x3=WEE3;


KII=transpose([f_x1,f_x2,f_x3])+...
u1*transpose([g1_x1,g1_x2,g1_x3])+...
u2*transpose([g2_x1,g2_x2,g2_x3])+...
u3*transpose([g3_x1,g3_x2,g3_x3])+...
u4*transpose([g4_x1,g4_x2,g4_x3])+...
u5*transpose([g5_x1,g5_x2,g5_x3])+...
u6*transpose([g6_x1,g6_x2,g6_x3])+...
u7*transpose([g7_x1,g7_x2,g7_x3])+...
u8*transpose([g8_x1,g8_x2,g8_x3])+...
u9*transpose([g9_x1,g9_x2,g9_x3])+...
u10*transpose([g10_x1,g10_x2,g10_x3]);

y=KII-KI;
zeta1=S(1)*y(1)+S(2)*y(2)+S(3)*y(3);
zeta2=S(1)*Z(1)+S(2)*Z(2)+S(3)*Z(3);
if zeta1>=(0.2*zeta2);
theta=1;

else
theta=0.8*zeta2/(zeta2-zeta1);
end
Wk=theta*y+(1-theta)*Z;
zeta3=S(1)*Wk(1)+S(2)*Wk(2)+S(3)*Wk(3);
D=(1/zeta3)*[Wk(1);Wk(2);Wk(3)]*[Wk(1) Wk(2) Wk(3)];
E=(1/zeta2)*[Z(1);Z(2);Z(3)]*[Z(1) Z(2) Z(3)];
H=H+D-E;

end

WE1=x1; % Xk
WE2=x2;
WE3=x3;


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
aa1=f(x1,x2,x3);
aa2=g_1(x1,x2,x3);
aa3=g_2(x1,x2,x3);
aa4=g_3(x1,x2,x3);
aa5=g_4(x1,x2,x3);
aa6=g_5(x1,x2,x3);
aa7=g_6(x1,x2,x3);

aa8=g_7(x1,x2,x3);
aa9=g_8(x1,x2,x3);
aa10=g_9(x1,x2,x3);
aa11=g_10(x1,x2,x3);

ghioud=[0,aa2,aa3,aa4,aa5,aa6,aa7,aa8,aa9,aa10,aa11]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Vk=max([0,aa2,aa3,aa4,aa5,aa6,aa7,aa8,aa9,aa10,aa11])
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f_x1=2*x1*x2*(x3+2);
f_x2=x1^2*(x3+2);
f_x3=x1^2*x2;


gradf=[f_x1,f_x2,f_x3];

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


gradg_1(1)=4*x2^3*x3/(71875*x1^5);
gradg_1(2)=-3*x2^2*x3/(71875*x1^4);
gradg_1(3)=-x2^3/(71875*x1^4);


gradg_1=[gradg_1(1),gradg_1(2),gradg_1(3)];


g2_x1=-x2*(12566*x1^3*(x2-x1))+x2*(4*x2-x1)*(37698*x1^2*(x2-x1)-12566*x1^3)+(-4.92/(12566*x1^3));
g2_x2=(4*x2-x1)*(12566*x1^3*(x2-x1))+x2*4*(12566*x1^3*(x2-x1))+x2*(4*x2-x1)*(12566*x1^3);
g2_x3=0;


gradg_2=[g2_x1,g2_x2,g2_x3];



g3_x1=-140.54/(x2^2*x3);
g3_x2=280*x1/(x2^3*x3);
g3_x3=140.54*x1/(x2^2*x3^2);

gradg_3=[g3_x1,g3_x2,g3_x3];

g4_x1=1/1.5;
g4_x2=1/1.5;
g4_x3=0;


gradg_4=[g4_x1,g4_x2,g4_x3];

g5_x1=-1;
g5_x2=0;
g5_x3=0;


gradg_5=[g5_x1,g5_x2,g5_x3];



g6_x1=1;
g6_x2=0;
g6_x3=0;


gradg_6=[g6_x1,g6_x2,g6_x3];



g7_x1=0;
g7_x2=-1;
g7_x3=0;


gradg_7=[g7_x1,g7_x2,g7_x3];



g8_x1=0;
g8_x2=1;
g8_x3=0;


gradg_8=[g8_x1,g8_x2,g8_x3];



g9_x1=0;
g9_x2=0;
g9_x3=-1;


gradg_9=[g9_x1,g9_x2,g9_x3];



g10_x1=0;
g10_x2=0;
g10_x3=1;


gradg_10=[g10_x1,g10_x2,g10_x3];


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

syms d1 d2 d3 s1 s2 s3 s4 s5 s6 s7 s8 s9 s10 u1 u2 u3 u4 u5 u6 u7 u8 u9 u10


C=gradf;
d=[d1,d2,d3];
q=C*d.'+ 0.5*(d*d.');
q=char(q);

L=q+...
u1*(gradg_1(1)*d1+gradg_1(2)*d2+gradg_1(3)*d3+aa2+s1)+...
u2*(gradg_2(1)*d1+gradg_2(2)*d2+gradg_2(3)*d3+aa3+s2)+...
u3*(gradg_3(1)*d1+gradg_3(2)*d2+gradg_3(3)*d3+aa4+s3)+...
u4*(gradg_4(1)*d1+gradg_4(2)*d2+gradg_4(3)*d3+aa5+s4)+...
u5*(gradg_5(1)*d1+gradg_5(2)*d2+gradg_5(3)*d3+aa6+s5)+...
u6*(gradg_6(1)*d1+gradg_6(2)*d2+gradg_6(3)*d3+aa7+s6)+...
u7*(gradg_7(1)*d1+gradg_7(2)*d2+gradg_7(3)*d3+aa8+s7)+...
u8*(gradg_8(1)*d1+gradg_8(2)*d2+gradg_8(3)*d3+aa9+s8)+...
u9*(gradg_9(1)*d1+gradg_9(2)*d2+gradg_9(3)*d3+aa10+s9)+...
u10*(gradg_10(1)*d1+gradg_10(2)*d2+gradg_10(3)*d3+aa11+s10);


% S=S^2 va +

Y1=diff(L,d1);
Y1=char(Y1);
Y2=diff(L,d2);
Y2=char(Y2);
Y3=diff(L,d3);
Y3=char(Y3);



Y4=diff(L,u1);
Y4=char(Y4);
Y5=diff(L,u2);
Y5=char(Y5);
Y6=diff(L,u3);
Y6=char(Y6);
Y7=diff(L,u4);
Y7=char(Y7);
Y8=diff(L,u5);
Y8=char(Y8);
Y9=diff(L,u6);
Y9=char(Y9);
Y10=diff(L,u7);
Y10=char(Y10);
Y11=diff(L,u8);
Y11=char(Y11);
Y12=diff(L,u9);
Y12=char(Y12);
Y13=diff(L,u10);
Y13=char(Y13);


Y14=u1*s1;
Y15=u2*s2;
Y16=u3*s3;
Y17=u4*s4;
Y18=u5*s5;
Y19=u6*s6;
Y20=u7*s7;
Y21=u8*s8;
Y22=u9*s9;
Y23=u10*s10;

%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%
M=0;
Y=0;

A=solve(Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y8,Y9,Y10,Y11,Y12,Y13,Y14,Y15,Y16,Y17,Y18,Y19,Y20,Y21,Y22,Y23,'d1','d2','d3','u1','u2','u3','u4','u5','u6','u7','u8','u9','u10','s1','s2','s3','s4','s5','s6','s7','s8','s9','s10');
A;
di1=A.d1; %d1 ( di1 natijeye solve)
di1=double(di1);

di2=A.d2;
di2=double(di2);

di3=A.d3;
di3=double(di3);



es1=A.s1;
es1=double(es1);

es2=A.s2;
es2=double(es2);

es3=A.s3;
es3=double(es3);

es4=A.s4;
es4=double(es4);

es5=A.s5;
es5=double(es5);

es6=A.s6;
es6=double(es6);

es7=A.s7;
es7=double(es7);

es8=A.s8;
es8=double(es8);

es9=A.s9;
es9=double(es9);

es10=A.s10;
es10=double(es10);


yu1=A.u1;
yu1=double(yu1);

yu2=A.u2;
yu2=double(yu2);

yu3=A.u3;
yu3=double(yu3);

yu4=A.u4;
yu4=double(yu4);

yu5=A.u5;
yu5=double(yu5);

yu6=A.u6;
yu6=double(yu6);

yu7=A.u7;
yu7=double(yu7);

yu8=A.u8;
yu8=double(yu8);

yu9=A.u9;
yu9=double(yu9);

yu10=A.u10;
yu10=double(yu10);




min_j=4; %s
max_j=13;
min_jj=14; %u
max_jj=23;

Q=[di1,di2,di3,es1,es2,es3,es4,es5,es6,es7,es8,es9,es10,yu1,yu2,yu3,yu4,yu5,yu6,yu7,yu8,yu9,yu10];
Q=double(Q)
aa,bb]=size(Q);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% for 'S'

for j=min_j:1:max_j
for p=aa:-1:1
p;
oo=j;
Q(p,oo);
if (Q(p,oo))<0
Q(p,Smile=[];
M=M+1;
end
end
Q;
[aa,bb]=size(Q);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% for 'U'
for jj=min_jj:1:max_jj
for p=aa:-1:1
p;
oo=jj;
if Q(p,oo)<0 % agar U manfi delete
Q(p,Smile=[];
M=M+1;
end
end
[aa,bb]=size(Q);
end
Q;

d1=Q(1,1); %Q yek satri shode(yek javab baghi mande:javabe KT)
d2=Q(1,2);
d3=Q(1,3);

d_charkhe=[d1' d2' d3'];
u1=Q(1,14);
u2=Q(1,15);
u3=Q(1,16);
u4=Q(1,17);
u5=Q(1,18);
u6=Q(1,19);
u7=Q(1,20);
u8=Q(1,21);
u9=Q(1,22);
u10=Q(1,23);


s_charkhe=[s1' s2' s3' s4' s5' s6' s7' s8' s9' s10'];
u_charkhe=[u1' u2' u3' u4' u5' u6' u7' u8' u9' u10'];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
norm_d=sqrt(d1^2+d2^2+d3^2);
epsilon2;
norm_d;
normd(ch)=norm_d;
ch;

Vk;
f(x1,x2,x3);

Vk;
epsilon1;

if norm_d<epsilon2 & Vk<epsilon1
TT=-10;
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% game 5: mohasebe R

rk=(u1+u2+u3+u4+u5+u6+u7+u8+u9+u10);
R=max([Rk,rk]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% game6: mohasebe X(k+1)
phi_k=f(x1,x2,x3)+R*Vk;
beta_k=gamma*norm_d^2;
HH=100;
n=0;
KL1=x1;
KL2=x2;
KL3=x3;


while HH>0
if TT<0
break
end
t_n=(0.5)^n;
x1=KL1+t_n*d1; %X(k+1,j)
x2=KL2+t_n*d2;
x3=KL3+t_n*d3;


WEE1=x1; %jadid
WEE2=x2;
WEE3=x3;


%V(k+1,j)
aa2=g_1(x1,x2,x3);
aa3=g_2(x1,x2,x3);
aa4=g_3(x1,x2,x3);
aa5=g_4(x1,x2,x3);
aa6=g_5(x1,x2,x3);
aa7=g_6(x1,x2,x3);
aa8=g_7(x1,x2,x3);
aa9=g_8(x1,x2,x3);
aa10=g_9(x1,x2,x3);
aa11=g_10(x1,x2,x3);



V1=max([0,aa2,aa3,aa4,aa5,aa6,aa7,aa8,aa9,aa10,aa11]); %V(k+1,j)
AA=phi_k-(t_n*beta_k);
phi_1=f(x1,x2,x3)+R*V1; % FI(k+1,j)
AAA=phi_1;
if AAA<AA
HH=-100;
else
n=n+1;
end
end
x1;
x2;
x3;

Xkbealave1charkhe=[x1' x2' x3']

end
x1;
x2;
x3;

Xbehine=[x1' x2' x3']

optimizedcost_function=f(x1,x2,x3)

end
پاسخ

اعلام خطا در فراخوانی درایه از ماتریس

#4
خواهش میکنم کمکم کنید، وقت ندارم
پاسخ

اعلام خطا در فراخوانی درایه از ماتریس

#5
(۱۳۹۵/۰۱/۲۹, ۰۹:۱۹ ب.ظ)jojolabger نوشته: خواهش میکنم کمکم کنید، وقت ندارم

سلام
اگه برنامه تون درست نشده من میتونم کمکتون کنم.

sbh400@yahoo.com
telegram: sbh400
پاسخ


پرش به انجمن:


کاربران در حال بازدید این موضوع: 1 مهمان

آخرین کلیدهای غیررایگان

شما هم می توانید کلیدهای غیررایگان منتشر کنید (بیشتر بدانید)