Why I can't integrate a matrix in Matlab?
1 ビュー (過去 30 日間)
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"
MRint=integral(fun, 0, 2, 'Arrayvalued', 1)
Walter Roberson 2021 年 8 月 22 日
You saved your code into a file named integral.m which is interfering with calling MATLAB's integral() function.
After that, MR will be a vector of constants.
That tells MATLAB that fun is an anonmous function that takes a single argument, and no matter what single argument is passed in, it should ignore the argument and return the content of the vector MR. It does not tell MATLAB that MR should be interpreted as a formula in i and integrated based on that formula. When you did the for i=1:t then i was given specific numeric values, 1, 2, 3, and so on, in turn, and that specific numeric value was used to calculate entries for MR.
You could integrate the vector of numeric values with respect to t, but the result is just going to be the numeric values times the difference in times.