I can't get input a trigonometric expression
Show older comments
clc;
b = input("Enter the initial limit value of the definite integral: ");
a = input("Enter the limit value that terminates the definite integral: ");
n = input("Enter the value of N: ");
h=(b-a)/n;
sum=0;
u = input("Enter the function to be integrated: ");
f=@(x) u;
for i=1:1:n-1
sum= sum + f(a+i*h);
end
result = h/2*(f(a)+f(b)+2*sum);
fprintf('%f',result);
It gives an error because of the "u" input. It throws an error when "u" writes a trigonometric expression to the input. I need your help, thanks.
Accepted Answer
More Answers (0)
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!