Incorrect number or types of inputs or outputs for function int
4 次查看(过去 30 天)
显示 更早的评论
Recently, I have been working on a school task. I've tried my best searching in how to deal with my problem in order to finishing this task, but I've hit a wall on how to finish this.
close all; clear a; clc;
syms x y
x = [-pi:pi/10:pi];
sum=0;
y1=0;
for k=1:1:100
y1=(((cos(k*pi)-1).*cos(k*x))./(-pi*(k^2)));
sum=sum +y1;
end
y=sum+pi/2;
figure(1)
plot(x,y)
axis([-4 4 0.5 2.7])
g=zeros(1, length(x));
a0= int(y,x,-pi,pi)/(2*pi);
an= int(y,x,-pi,pi).*cos(n*x)/pi;
bn= int(y,x,-pi,pi).*sin(n*x)/pi;
for n=1:1:10
f=an*cos(n*x)+bn*sin(n*x);
g=g+f;
end
figure(2)
plot(x,g+a0)
2 个评论
Dyuman Joshi
2023-12-1
In int() function, x is expected to be a symbolic variable, but you have over-written it as a numeric array. Thus you get that error.
Since I do not know what you are trying to do here, I can not provide any suggestion.
Please provide more information and specify the objective.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!