How to calculate the error(pls see the attachment-pg1)? (data and formula is written in the attachment) Do i have to use a for loop here? How to solve this problem?

 채택된 답변

Michael Haderlein
Michael Haderlein 2015년 2월 18일

0 개 추천

Dou you mean
err=sqrt(sum((M-P).^2)/numel(M));
I guess "i" does not go to infinity but only to 2000 and the data in your file is incomplete and should have 2000 values each (M and P).

댓글 수: 7

Chathu
Chathu 2015년 2월 19일
편집: Chathu 2015년 2월 19일
@ Michael- thank you so much for your response. I have attached the original data set.
The issue i am having here is something very obvious: i obtained M=104 and P=100 values when i run my code. How can i take off the zeros(Pls look at the M sheet) out of the data set and make 1st value to zero. My purpose here is to make M and P dimensions same. Can you kindly tell me how to overcome this issue?
To remove the zeros:
M(M==0)=[];
But I see only two zeros (7 and 42), so M will still have more elements than P. Also, this means you shift M. Whether this is a problem or not depends on the case.
If you want to ensure to always take the first values, you can use
minL=min(numel(M),numel(P);
and apply it with
err=sqrt(sum(M(1:minL)-P(1:minL).^2)/minL);
This will simply ignore the extra values at the end of your arrays.
Chathu
Chathu 2015년 2월 19일
Micheal- thank you so much for your response.
You are right, if i remove zeros i am shifting M. I totally forgot that point-my mistake:( but thanks for pointing it out. Can i ask you my qu in different way(sorry, i would have asked it earlier) Suppose i want to:
1)Make 1st M and P value to zero 2) Afterwards,make M and P dimensions same. So then i can calculate the error. Is it possible to do?
If you want to set a value to zero, just do it:
M(1)=0;
In my code above, values at the end of the array are just ignored. If you want to delete values at the end of your data to equalize the size, just do it with
M=M(1:minL);
P=P(1:minL);
The definition of minL is like shown in the previous post.
Chathu
Chathu 2015년 2월 20일
편집: Chathu 2015년 2월 20일
Michael- thank you so much for your time and effort. Really appreciate your help. I am getting a value(see below) like this. 0.0000e+00 + 4.3938e+12i
I wonder why i am getting an 'i' here? do you have any idea?
Torsten
Torsten 2015년 2월 20일
err=sqrt(sum((M(1:minL)-P(1:minL)).^2)/minL);
Best wishes
Torsten.
Chathu
Chathu 2015년 2월 20일
@ Torsten- Perfect !!!
Finally i obtained estimated values for the error. Thank you sooo much. Appreciate it.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

질문:

2015년 2월 18일

댓글:

2015년 2월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by