- Function "C" calls "E" which in turn calls "Z",
- "Z" calls "hbar" which returns the output with the size same as input
Getting error is this code, there are multiple input values of "betasqr" and "sbar" for multiple output values of Wbar, Fbar, fbar and Ybar.
1 回表示 (過去 30 日間)
古いコメントを表示
betasqr = [0.2 0.4];
gamma = 0.3;
psi = 0.001;
mu = 1.0;
sbar = [1/0.02 1/0.04];
a = 2;
% Steps for finding dimensionless load carrying capacity (Wbar) of the bearing
hbar = @(x) a - a.*x + x;
A = @(x) 4 .* (hbar(x) .^ 3) + sbar .* (hbar(x) .^ 4) - sbar.*betasqr.*gamma .* (hbar(x) .^ 2) .* sqrt(x .* (1-x)) ;
B = @(x) (1 + sbar .* hbar(x)) .* (1 - betasqr .* sqrt(x .* (1-x)));
G = @(x) 12 * psi + A(x) ./ B(x);
Z = @(x) 12 .* hbar(x) + 6.*sbar .* (hbar(x) .^ 2) - 2.*sbar.*betasqr.*gamma .* sqrt(x .* (1-x)) ;
E = @(x) Z(x) ./ (1 + sbar .* hbar(x));
C = @(x) E(x) ./ G(x);
IntEbyG = integral(C,0,1);
D = @(x) 1 ./ G(x);
IntGinv = integral(D,0,1);
Q = IntEbyG/IntGinv;
Wdash = @(x) x.*(E(x)-Q) ./ G(x);
IntWdash = integral(Wdash,0,1);
Wbar = (mu/12) - IntWdash
% Steps for finding dimensionless frictional force (Fbar) of the slider
I = @(x) hbar(x) .* (2 + sbar .* hbar(x)) .* (E(x) - Q );
J = @(x) 2 .* G(x) .* (1 + sbar .* hbar(x)) .* (1 - betasqr .* sqrt(x .* (1-x)));
Fdash = @(x) (sbar ./ (1 + sbar .* hbar(x))) + I(x) ./ J(x);
Fbar = integral(Fdash,0,1)
% Steps for finding coefficient of friction (fbar)
fbar = Fbar/Wbar % Coefficient of friction
% Steps for finding dimensionless form of x coordinate of center of pressure(Ybar)
L = @(x) (x.^2).*(E(x)-Q) ./ G(x);
IntL = integral(L,0,1);
Ybar = ((mu/24)-(0.5*IntL)) / Wbar
getting the following error:
Arrays have incompatible sizes for this operation.
Error in table1inclinea>@(x)12.*hbar(x)+6.*sbar.*(hbar(x).^2)-2.*sbar.*betasqr.*gamma.*sqrt(x.*(1-x)) (line 13)
Z = @(x) 12 .* hbar(x) + 6.*sbar .* (hbar(x) .^ 2) - 2.*sbar.*betasqr.*gamma .* sqrt(x .* (1-x)) ;
Error in table1inclinea>@(x)Z(x)./(1+sbar.*hbar(x)) (line 14)
E = @(x) Z(x) ./ (1 + sbar .* hbar(x));
Error in table1inclinea>@(x)E(x)./G(x) (line 15)
C = @(x) E(x) ./ G(x);
Error in integralCalc/iterateScalarValued (line 314)
fx = FUN(t);
Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 87)
Q = integralCalc(fun,a,b,opstruct);
Error in table1inclinea (line 16)
IntEbyG = integral(C,0,1);
0 件のコメント
回答 (1 件)
Ramtej
2023 年 9 月 8 日
Hi Avinash,
I understand thart you are trying to find dimensionless load by integrating your custom anonymous functions.
The "integral(C,0,1)" function computes the integration by passing the array of "x" values spaced between (0,1) to the function "C".
When the command "IntEbyG = integral(C,0,1);" is executed
The error occurs when you try to compute "6.*sbar .* (hbar(x) .^ 2)", where "sbar" is of size (1,2) and "(hbar(x).^ 2)" is of size (1, n). It's important to note that you cannot multiply two row vectors of different sizes (greater than 1).
To resolve this issue, you can refer to the "Compatible Array Sizes for Basic Operations" documentation, which provides a detailed view on compatible sizes for basic operations and redefine your function accordingly.
You can find the documentation at this link: https://in.mathworks.com/help/matlab/matlab_prog/compatible-array-sizes-for-basic-operations.html
Hope this resolves your query!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Behavior and Psychophysics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!