Incorrect number or types of inputs or outputs for function int
조회 수: 19 (최근 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!