calculate the value by using a formula
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
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
2015 年 2 月 18 日
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 件のコメント
@ 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?
Michael Haderlein
2015 年 2 月 19 日
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
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?
Michael Haderlein
2015 年 2 月 19 日
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.
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
2015 年 2 月 20 日
err=sqrt(sum((M(1:minL)-P(1:minL)).^2)/minL);
Best wishes
Torsten.
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 についてさらに検索
タグ
タグが未入力です。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
