I need to partition my plot

1 view (last 30 days)
Lidia Toscano
Lidia Toscano on 13 Jan 2017
Commented: Lidia Toscano on 13 Jan 2017
I have a data set of 899 points. I can partition my data to plot the first 300 points but I don't know how to do that for the equation that computes the distance_error_rms:
distance_error_rms=sqrt(sum(sub_off_radial)/length(gps_distance))
I want to plot the first 300 points and I want the distance error rms to match that plot. Also, I want to print the answer on the plot. How do I do that?
off_radial=0; %distance away from leader in meters
gps_distance=acos(cos(deg2rad(90-LatA)).*cos(deg2rad(90-LatWP))+sin(deg2rad(90-LatA)).*sin(deg2rad(90-LatWP)).*cos(deg2rad(LonA-LonWP)))*6371*1000;
sub_off_radial=((gps_distance-off_radial).^2);
distance_error_rms=sqrt(sum(sub_off_radial)/length(gps_distance)) %How do I partition this for 1-300 points
figure('Color','White')
plot(gps_distance(1:300)) %This partitions my plot 1-300
ylabel('GPS Distance - meters')
xlabel('Samples at 10Hz')
legend('GPS Distance - 899 Sampes')
title('RMS off radial=0 - 10Hz 02Dec2016 Test 1')
grid
Thanks in advance
Lidia

Accepted Answer

John Chilleri
John Chilleri on 13 Jan 2017
Hello,
It seems like you could just redefine distance_error_rms at the end as:
distance_error_rms = distance_error_rms(1:300);
Otherwise when you create it, place a (1:300) on all vectors in its computation.
To print your answer on the plot, use text.
TLDR for text: type text(x,y,txt) where x,y specifies the location of the string, and txt is the string to be printed.
Hope this helps, please comment if I didn't cover something, I answered this in a hurry!
  1 Comment
Lidia Toscano
Lidia Toscano on 13 Jan 2017
Thank you for your quick response, that was just what I needed.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!