Maximum error between two graphs?
47 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Kautuk Raj
il 2 Giu 2023
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 Commenti
Vedere anche
Categorie
Scopri di più su Directed Graphs in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!