"Inner matrix dimensions must agree"

Hi all,
I know this is simple, but I still can't see the solution. I'm trying to plot a function which uses the 4th power of sinh and cosh. I can't figure out how to communicate it to MATLAB properly, so
k = 1.3 * 10^(-23);
T1 = 100;
T2 = 200;
T3 = 300;
j = 0:10:500;
lambda = 2* cosh(j) * (1 + 2 * sqrt(4 * sinh(j) * sinh(j) * sinh(j) * sinh(j) +1) );
F1 = k * T1 * log(lambda);
F2 = k * T2 * log(lambda);
F3 = k * T3 * log(lambda);
plot(j, F1(j), j, F2(j), j, F3(j))
hleg1 = legend('at 100 K', 'at 200 K', 'at 300 K');
results in
Error using *
Inner matrix dimensions must agree.
Error in Energy (line 8)
lambda = 2* cosh(j) * (1 + 2 * sqrt(4 * sinh(j) * sinh(j) * sinh(j) *
sinh(j) +1) );
Could anyone tell me how to reformulate line 8?
Thanks!

 채택된 답변

Walter Roberson
Walter Roberson 2013년 3월 14일

0 개 추천

Change
sqrt(4 * sinh(j) * sinh(j) * sinh(j) * sinh(j) +1)
to
sqrt(4 * sinh(j).^4 + 1)

댓글 수: 3

Nina
Nina 2013년 3월 14일
Thank you! Unfortunately, I'm still getting the same error message. Do you know any alternative solution?
... cosh(j) .* (1 + ...
and
plot(j, F1, j, F2, j, F3)
Nina
Nina 2013년 3월 14일
Yes, that solved it! Thank you very much, Christian!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

제품

질문:

2013년 3월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by