had a trouble in the following program

x=55125;
y=54900;
function[ABSE,MSE,RMSE,SNR]=objectiveanalysis(x,y)
L=length(x);
y=y(1:L);
ABSE=sum(abs(x-y));
MSE=(sum(((x-y).^2))).*(1/L);
RMSE=MSE.^.5;
nem=sum((x).^2);
den=sum(((x-y).^2));
SNR1=nem./den;
SNR=10*log10(SNR1);
fprintf ('Absolute Error : %g\n\n',ABSE);
fprintf ('Mean Square Error : %g\n\n',MSE);
fprintf ('Root Mean Square Error : %g\n\n',RMSE);
fprintf ('Signal to Noise Ratio : %g\n\n',SNR);
note... actuly x is my speech signal and its length is i define same y is my encoded speech and its length i defined

댓글 수: 1

Image Analyst
Image Analyst 2014년 2월 24일
You forgot to describe the trouble. What's going wrong?

답변 (2개)

Mischa Kim
Mischa Kim 2014년 2월 24일

0 개 추천

The first two lines of your code (assigning values to x and y) you should execute in the MATLAB command window. Only the code including and following the function definition should be in the function file (named objectiveanalysis.m).
Image Analyst
Image Analyst 2014년 2월 24일

0 개 추천

Or, have it all in a single m-file called test (if you want to do it that way, in a single m-file):
function test
x=55125;
y=54900;
[ABSE,MSE,RMSE,SNR]=objectiveanalysis(x,y)
function[ABSE,MSE,RMSE,SNR]=objectiveanalysis(x,y)
L=length(x);
y=y(1:L);
ABSE=sum(abs(x-y));
MSE=(sum(((x-y).^2))).*(1/L);
RMSE=MSE.^.5;
nem=sum((x).^2);
den=sum(((x-y).^2));
SNR1=nem./den;
SNR=10*log10(SNR1);
fprintf ('Absolute Error : %g\n\n',ABSE);
fprintf ('Mean Square Error : %g\n\n',MSE);
fprintf ('Root Mean Square Error : %g\n\n',RMSE);
fprintf ('Signal to Noise Ratio : %g\n\n',SNR);

이 질문은 마감되었습니다.

질문:

2014년 2월 24일

마감:

2021년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by