I'm scripting & getting a error "Error using * Inner matrix dimensions must agree." Please help me debug this.
Info
This question is closed. Reopen it to edit or answer.
Show older comments
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 Comments
J. Webster
on 28 Apr 2016
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
on 29 Apr 2016
Answers (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:
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!