Why I can't integrate a matrix in Matlab?
Show older comments
So for a while it worked, but than I ran the program again, and somehow it doesn't work again, though I did not change the code. The error message: "Attempt to execute SCRIPT integral as a function"
The code:
t=3000
a=1.044
b=-3.484*10^(-5)
k=0.0711
n=0.461
for i=1:t
MR(i)=a*exp(-k*(i^(n)))+b*i;
end
fun=@(i) MR;
MRint=integral(fun, 0, 2, 'Arrayvalued', 1)
5 Comments
Wan Ji
on 22 Aug 2021
t=3000;
a=1.044;
b=-3.484*10^(-5);
k=0.0711;
n=0.461;
fun= @(i)a*exp(-k*(i^(n)))+b*i;
MRint=integral(fun, 0, 2, 'Arrayvalued', 1);
Jani
on 22 Aug 2021
Wan Ji
on 22 Aug 2021
Hey, Jani
Firstly you need tell what your script want to achieve, e.g., you integrate a function called 'fun', so which variable is the argument to this inline function, 'i' or other variables?
Jani
on 22 Aug 2021
Wan Ji
on 23 Aug 2021
Look at Walter Roberson's answer. Good solution to your problem
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements 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!


