Undefined function or method 'int' for input arguments of type 'double'. Error in ==> @(Y,n,t)int(cos((n*pi)*t).*Y,t,0,2)
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
t=linspace(0,0.4,100);
f=0;
for n=0:1:5;
evalin(symengine,'assume(n,Type::Integer)');
t=[0,0,0.8,0.8,2,2];
Y=[0,1,1,-1,-1,1];
line(t,Y,'color','r','linewidth',2)
grid on;hold on;
a=@(Y,n,t)int(cos((n*pi)*t).*Y,t,0,2);
b=@(Y,n,t)int(Y.*sin((n*pi)*t),t,0,2);
f=f+a(Y,n,t)*cos((pi*n)*t)+b(Y,n,t)*sin((pi*n)*t);
plot(t,f,'k','linewidth',2)
end
0 comentarios
Respuestas (2)
Mikhail
el 22 de Ag. de 2014
Editada: Mikhail
el 22 de Ag. de 2014
Typically this means that matlab doesn't know this function. Try to type "help int" in the command window. You can check this way if you have such function. May be you have to install additional packages for certain functions.
0 comentarios
John D'Errico
el 22 de Ag. de 2014
Editada: John D'Errico
el 22 de Ag. de 2014
INT is a tool from the symbolic toolbox. It has no idea what you want it to do when you just pass it a list of numbers.
In fact, I have no idea either what you intend, given the vectors t and Y that you have used.
t=[0,0,0.8,0.8,2,2];
Y=[0,1,1,-1,-1,1];
Are you somehow hoping that MATLAB will be smart enough to recognize that this list of points corresponds to a polygon in the (t,Y) plane, and then do an integration over the polygon, or maybe around the perimeter? Computers don't read your mind.
Yes, I see that BEFORE you wrote those lines where you defined t and Y, you ALSO defined t using linspace. Again, COMPUTERS DON'T READ MINDS. MATLAB has no idea which version of t you want here, so it uses the LAST t that you defined, here inside the for loop.
Even if you use trapz (which IS a tool for numerical integration of a list of points) you need to consider what it is you are doing, and IF that makes mathematical sense. Sorry, but from what I have seen of the code above, it makes no sense at all. So, again, you need to think carefully about what you need, and then write careful code that represents your goal.
1 comentario
Nabhdeep Bansal
el 23 de Ag. de 2014
Editada: Walter Roberson
el 10 de Mzo. de 2019
Ver también
Categorías
Más información sobre Numerical Integration and Differentiation en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!