a***m 发帖数: 74 | 1 Hello,请高手指点:
I am using Matlab integral function. I need to integrate a function of one
variable t for different values of a parameter y. The output is a vector for
each value of the parameter y.
for example:
function f = myfunc(x, a)
b = 0.5;
f = a+quad(@myInt, 0, 0.5*pi, [], b, x);
function v = myInt(t,b,x)
v = cos(t*b).*x;
%main.m
a = 4;
x = [ 1,2,3];
f = myfunc(x,a);
I got error message says:
??? Error using ==> mtimes
Inner matrix dimensions must agree.
Error in ==> myInt at 2
v = cos(t*b). | a***m 发帖数: 74 | 2 I can evaluate integral for each value of parameter by using a for loop in
main function. If one look for better codes, are there ways to vectorize
quad function?
Many thanks! |
|