Incompatible Array Size/Mathematical Input Error

조회 수: 8 (최근 30일)
Harrison Forlines
Harrison Forlines 2022년 9월 20일
답변: Walter Roberson 2022년 9월 20일
I was trying to get the "exact" function to work its rather long though, and I've typed it all out below in MATLAB.
For the exact equation I really don't know how I shoud even input the summation, since I've never worked with one like that before, so I suspect I've done that wrong or maybe I misinterperated the instuctions? But If anyone sees what I've done wrong I'd really appriciate it.
So far, I've typed everything in as follows:
clear;clc
x = 3.*[8 7 4];
V = [8 7 4];
R = [8 7 4];
Eo = V./(2.*R);
r = ((2.*R) + x)./(2.*R);
B = acosh(r);
n = 1:100;
S = x./(2.*R);
f = ((1./sinh(2.*n.*B)).*(1+r+(sinh(B).*((coth(2.*n.*B))))./(1-r-(sinh(B).*(coth(2.*n.*B)))).^2)+(cosh(2.*B))+r+(((2.*r)+1).*(sinh(B).*((coth(2.*n.*B)))))./(((cosh(2.*B))-r-(((2.*r)-1).*(sinh(B).*((coth(2.*n.*B)))))).^2));
Arrays have incompatible sizes for this operation.
E_max_simp = (Eo./4.*S).*(1+(2.*S)+sqrt((1+(2.*S)).^2)+8);
E_max_exac = Eo(1+((2.*r+1)/(2.*r-1)^2))+sinh(B).*syssum(f,n,1,inf);

답변 (1개)

Walter Roberson
Walter Roberson 2022년 9월 20일
x = 3.*[8 7 4];
V = [8 7 4];
R = [8 7 4];
Eo = V./(2.*R);
r = ((2.*R) + x)./(2.*R);
B = acosh(r);
syms m n integer
S = x./(2.*R);
E_max_simp = (Eo./4.*S).*(1+(2.*S)+sqrt((1+(2.*S)).^2)+8)
E_max_simp = 1×3
3 3 3
f = ((1./sinh(2.*n.*B)).*(1+r+(sinh(B).*((coth(2.*n.*B))))./(1-r-(sinh(B).*(coth(2.*n.*B)))).^2)+(cosh(2.*B))+r+(((2.*r)+1).*(sinh(B).*((coth(2.*n.*B)))))./(((cosh(2.*B))-r-(((2.*r)-1).*(sinh(B).*((coth(2.*n.*B)))))).^2));
E_max_exac = Eo .* (1+((2.*r+1)/(2.*r-1).^2))+sinh(B).*symsum(f,n,1,m);
E_max_exac_100 = vpa(subs(E_max_exac, m, 100))
E_max_exac_100 = 
Notice that your E_max_simp is constant. Notice that your Eo is a vector that has all entries work out to exactly 1/2, and notice that your E_max_simp does not involve n or any sum.. everything happens to cancel out leaving constants.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by