I'm scripting & getting a error "Error using * Inner matrix dimensions must agree." Please help me debug this.
信息
此问题已关闭。 请重新打开它进行编辑或回答。
显示 更早的评论
qd=[0:0.1:1];
qf=[0:0.1:1];
micro=0.8;
pa=0.5;pd=0.5;Ptd=1;Esd=0.05;
Esa=0.05; Ptsa=0.3;beta=0.2;
temp1 = micro.*(1 - micro.*pa*qd);
temp2 = pd*(Ptd - Esd);
temp3 = pa*(qf*(Ptd - Ptsa - Esa));
temp4 = qd*(-Ptsa -Esa);
temp5 = micro.^2*pa*qd;
temp6 = pd*(Ptd - Esa);
temp7 = pa*(qf*(Ptd - Ptsa -Esa));
temp8 = pa*(qd*(-Ptsa - Esa));
*Usx = temp1*[temp2 + temp3 + temp4] + temp5*[temp6 + temp7 + temp8];*
plot(qd/qf, Usx,'-b');
xlabel('Dropping/Forwarding Propability')
ylabel('Utility of Attacker/Source Victim Uax/Usx')
title('Utility function as a function of Forwardding/Dropping propability of Packets')
The Error Message in Command Window is Error using * Inner matrix dimensions must agree.
Error in sample1 (line 14) * Usx = temp1[temp2 + temp3 + temp4] + temp5*[temp6 + temp7 + temp8];**
2 个评论
J. Webster
2016-4-28
when posting code, it'll be much more readable if, in the editor, you highlight the code and click the "{ } code" button located just above the text area.
ALOK SHUKLA
2016-4-29
回答(1 个)
Usx = temp1.*[temp2 + temp3 + temp4] + temp5.*[temp6 + temp7 + temp8];
That works without error. But you are the only one who can check if you algorithm is correct. To avoid making the same mistake again read and understand the difference between matrix and array operations:
0 个评论
此问题已关闭。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!