matlabapproximationfunction-approximation

How to correctly plot the error of a numerical algorithm in MATLAB


I would like to display the error made after the insertion of each approximation point in my numerical algorithm. Here is the plot that I get:

enter image description here I don't want to display the error like that, since it is not clear how the value of it changes after the insertion of each point. I'd like to plot the error this way (picture taken from a paper):

enter image description here

In other words, I want the Y Axis to contain values from 10^(-1) to 10^(-6) Here is the code that I use:

rms_res = norm(residual)/sqrt(lres);
errors = [errors rms_res];
% some code for other computation
% plot
plot(coord_ctrs, (errors), '.');
line(coord_ctrs, (errors));

How can I do that ? Thank you.


Solution

  • What is the exact problem that you are facing? It is not clear what you are asking for

    If your problem is keeping the visualization of the data within those limits just use ylim([10^-6 10^-1])

    I would suggest you use an animatedline within a timed for-loop to see the evolution of the error from your algorithm. If you need to display both graphs, the algorithm's output, and the error, consider using double-axis with yyaxis