Integration by matlab

조회 수: 1 (최근 30일)
reem
reem 2011년 5월 30일
Good morning,
Please,I have a problem in integration
please anyone help me and I will appreciate it so much.
My program
N=400;
f1=1; % Frequency of the cosine wave
FS=200; % Sampling Frequency
t=1:400;
n=0:N-1;
X= @(Q)cos((2*pi*f1*n/FS)+Q);
M=quadgk(X,0,(2*pi));
disp(M)
plot(t,M)
grid;
title('cosinewave ');
xlabel('Time index');
ylabel('cosine value');
Kind regards

채택된 답변

Matt Fig
Matt Fig 2011년 5월 30일
Use this instead:
M=quadv(X,0,(2*pi));
%
%
%
In the future, you need to be more specific than just saying that you have an error. You should have said this:
This code produces an error, and here is the error message:
??? Error using ==> plus
Matrix dimensions must agree.
Error in ==> @(Q)cos((2*pi*f1*n/FS)+Q)
Error in ==> quadgk>evalFun at 363
fx = FUN(x);
Error in ==> quadgk>f1 at 381
[y,too_close] = evalFun(tt);
Error in ==> quadgk>vadapt at 275
[fx,too_close] = f(x);
Error in ==> quadgk at 214
[q,errbnd] = vadapt(@f1,interval);
>>
  댓글 수: 3
Matt Fig
Matt Fig 2011년 5월 30일
Not when I ran the code. Did you change more than the line I showed you to change? The only line I changed from what you originally pasted was the one line I showed, and I got a plot with no problems.
reem
reem 2011년 5월 30일
Sorry,there is no any problem
In the future, I will be more specific
Thank you so so much, you helped me a lot now and before, and I will not forget your help forever
You are the best teacher for me
I benefited from you a lot

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by