Error while integrating with changing value of alpha and beta
1 回表示 (過去 30 日間)
古いコメントを表示
I am getting error in this code
x=-5:0.1:5;
a=5;
alpha=linspace(0,30*pi/180,12);
beta=linspace(0,30*pi/180,12);
Z=3;
for i=1:length(x)
z(i)=sqrt(a^2-x(i).^2);
Q1=quad(@(y)pi/180*sqrt((a^2-x(i)^2-y.^2).*( ( -Z*sin(beta).*sin(alpha) - y.*cos(alpha) ).^2+( cos(alpha)*x(i) + cos(beta)*sin(alpha) *Z) .^2)),0,z(i));
if Q1>=pi/2
Q1= rem(Q1,pi/2);
elseif Q1<=-pi/2
Q1= rem(Q1,-pi/2);
end
Q2(i)=abs(Q1);
end
k=0.23;
Fn=2500;wo=15;va=5;
h=-((3*k*Fn*wo)/(pi*va*a^3))*Q2
plot(x,h)
grid on
xlabel('tool Path')
ylabel('Material Removal Depth')
I am getting this error
Error in quad (line 67)
y = f(x, varargin{:});
Error in Untitled6 (line 8)
Q1=quad(@(y)pi/180*sqrt((a^2-x(i)^2-y.^2).*( ( -Z*sin(beta).*sin(alpha) - y.*cos(alpha) ).^2+( cos(alpha)*x(i) +
cos(beta)*sin(alpha) *Z) .^2)),0,z(i));
0 件のコメント
回答 (1 件)
Walter Roberson
2021 年 4 月 30 日
編集済み: Walter Roberson
2021 年 4 月 30 日
Q1=quad(@(y)pi/180*sqrt((a^2-x(i)^2-y.^2).*( ( -Z*sin(beta).*sin(alpha) - y.*cos(alpha) ).^2+( cos(alpha)*x(i) + cos(beta)*sin(alpha) *Z) .^2)),0,z(i));
alpha and beta are vectors. cos(beta) * sin(alpha) is an attempt to use the * operator between two 1 x 12 arrays, but * is algebraic matrix multiplication which requires that the second dimension of the first operand be the same as the first dimension of the second operand.
quad is going to pass in a vector of y values, not a scalar. y.*sin(alpha) is going to be a size mismatch unless y happens to be a column vector, but it will be a row vector.
Each of the function calls must return a vector the same size as the input.
Please consider what you are doing further. If the quad worked with the vector of angles you would expect one result for each angle, but your code expects a single scalar output.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Function Creation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!