Incorrect number or types of inputs or outputs for function int
19 views (last 30 days)
Show older comments
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 Comments
Dyuman Joshi
on 1 Dec 2023
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.
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!