필터 지우기
필터 지우기

Incorrect number or types of inputs or outputs for function int

조회 수: 19 (최근 30일)
윤형
윤형 2023년 12월 1일
이동: Torsten 2023년 12월 1일
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
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.
윤형
윤형 2023년 12월 1일
I want to Fourier transform the 'y' function using Euler's formulas.

댓글을 달려면 로그인하십시오.

답변 (1개)

Torsten
Torsten 2023년 12월 1일
이동: Torsten 2023년 12월 1일
I don't understand your question. The Fourier series of y is y itself because it is already given as a series of cos(k*x) terms.

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by