Filter löschen
Filter löschen

??? Error using ==> times Matrix dimensions must agree.

1 Ansicht (letzte 30 Tage)
Captain Singh
Captain Singh am 1 Jan. 2015
Kommentiert: Captain Singh am 6 Jan. 2015
Happy New year to everyone. When I am executing the below given program, I got the error message " ??? Error using ==>times Matrix dimensions must agree." Please check the problem and help me to resolve the issue,
for p1=4:1:12
E1 = sqrt((p1^.2)-(Mc^.2));
f1 = 1./(exp(E1/T) + 1);
for p2=4:1:12
E2 = sqrt((p2^.2)-(Mc^.2));
f2 = 1./(exp(E2/T) + 1);
v_rel = sqrt(((p1^.2).*(p2.^2) - (Mc.^4))/((p1^.2).*(p2.^2) + (Mc.^2).*((p1^.2) + (p2.^2) + (Mc.^4))))
end
dp12 = p2(2:end) - p2(1:end-1);
Lambda_f_Jpsi1 = sum(dp12.*p2.*p2.*f2.*v_rel.*sigma_f_Jpsi)
Lambda_f_Jpsip1 = sum(dp12.*p2.*p2.*f2.*v_rel.*sigma_f_Jpsip)
Lambda_f_ChiC1 = sum(dp12.*p2.*p2.*f2.*v_rel.*sigma_f_Chic)
end
dp11 = p1(2:end) - p1(1:end-1);
Lambda_f_Jpsi = (1./(pi.^4)).*sum(dp11.*p1.*p1.*f1.*Lambda_f_Jpsi1)
Lambda_f_Jpsip = (1./(pi.^4)).*sum(dp11.*p1.*p1.*f1.*Lambda_f_Jpsip1)
Lambda_f_ChiC = (1./(pi.^4)).*sum(dp11.*p1.*p1.*f1.*Lambda_f_ChiC1)
Please Help me. Thank you.

Antworten (2)

Image Analyst
Image Analyst am 1 Jan. 2015
Do you really mean to raise p1 and p2 to the 0.2 power, like p1^.2? Or did you mean p1.^2? Actualy p1 and p2 are scalars so you don't even need the dot unless you want p1 ^ (0.2).
What is the value of Mc and T? Are they arrays?
Anyway, please post the complete error text - ALL THE RED TEXT, not just a small snippet of it like you did. I don't know what line it's complaining about.
  4 Kommentare
Captain Singh
Captain Singh am 1 Jan. 2015
yes, after putting these line before the line no. 267, it has given :
Name Size Bytes Class Attributes
dp12 1x0 0 double
Name Size Bytes Class Attributes
p2 1x1 8 double
Name Size Bytes Class Attributes
f2 1x1 8 double
Name Size Bytes Class Attributes
v_rel 1x1 8 double
Name Size Bytes Class Attributes
sigma_f_Jpsi 1x1000 16000 double complex
and end up with same error as earlier.
Image Analyst
Image Analyst am 1 Jan. 2015
Does it worry you that the size of dp12 is 1-by-0? What about that sigma_f_Jpsi is filled with a thousand complex numbers?

Melden Sie sich an, um zu kommentieren.


Star Strider
Star Strider am 1 Jan. 2015
What line is throwing the error? Please post the full error, and the full line that is throwing it.
What’s Mc?
Unless we know what it is, we can’t run your code. If we can’t run your code, we can’t isolate the problem.
  14 Kommentare
Image Analyst
Image Analyst am 2 Jan. 2015
that should be okay. But what about the last term? Did you leave it off or did you change your equation? What about the complex number, sigma_f_Jpsi? It has 1000 complex numbers. You can't multiply a 1-by-8 array by a 1-by-1000 array element-by-element. We can't really help more because you did not put in any comments to help us figure out what you want to do. All we can see is what you put, which we know is wrong, but we don't know how to fix it because you've given us no guidance (like in the form of comments) as to what you really want to do.
Captain Singh
Captain Singh am 6 Jan. 2015
Thanks for comment, that problem has been resolved.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by