Maximum error between two graphs?
12 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I have data for two graphs and am looking for a way to find the maximum error(representing the maximum distance between the two) using Matlab. I am supposed to get 0.02.
What is a the most accurate way to do this on Matlab?
Thanks!
0 件のコメント
回答 (1 件)
Kautuk Raj
2023 年 6 月 2 日
To find the maximum error between two graphs in MATLAB, we can follow these steps:
The first step is to evaluate both graphs at a set of points using the linspace function. An an example, I will create a vector x of 100 equally spaced points between 0 and 1, and evaluate both graphs at these points using the feval function.
x = linspace(0, 1, 100);
y1 = feval(graph1, x);
y2 = feval(graph2, x);
In the above code, graph1 and graph2 are the function handles for the two graphs we want to compare.
Next, we will compute the absolute difference between the two graphs at each point using the abs function and find the maximum difference using the max function.
diff = abs(y1 - y2);
max_diff = max(diff);
The value of max_diff represents the maximum distance between the two graphs at any point in the range of x.
I am assuming that we have access to function handles for both graphs in my answer.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!