Why I can't integrate a matrix in Matlab?
Mostrar comentarios más antiguos
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 comentarios
Wan Ji
el 22 de Ag. de 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
el 22 de Ag. de 2021
Wan Ji
el 22 de Ag. de 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
el 22 de Ag. de 2021
Wan Ji
el 23 de Ag. de 2021
Look at Walter Roberson's answer. Good solution to your problem
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



