writting down the code for the function
1 次查看(过去 30 天)
显示 更早的评论
Attached file has the function and here is my matlab code pasted below
function y = myFunction(x, n)
if n == 1
y = 4 * sin(x) / (25*x + sin(25));
else
y = 2 * tan(5*n) / bi;
end
end
% Define the values of x and n
n = 2;
% Call the function to calculate y
y = myFunction(x, n);
% Display the result
disp(y);
0 个评论
回答(1 个)
Walter Roberson
2024-2-7
y = 4 * sin(x) / (25*x + sin(25));
That is not vectorized. It needs to be
y = 4 * sin(x) ./ (25*x + sin(25));
Also remember that the parameters to the trig functions are in radians . If you want degrees, use sind
9 个评论
Walter Roberson
2024-2-8
Bi_value is symbolic, not numeric. You cannot num2str() it. You can char() it.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!