how to perform one plot

Hi, I am waiting for to optimize the plot of some arrays I attached my figure to showing you my problem: I would to obtain a "cleaned" curve. I tried with the following code but it is not the solution:
my_datax = min(x):10:max(x)
my_datay = min(y):10:max(y)
neither with others steps
Do you have any suggestions? Thank you

2 Comments

What exactly do you mean when you say "cleaned"? Explain very explicitly what you would like to see as the end result.
I would to see a light line such as the last section

Sign in to comment.

Answers (2)

It looks as though you are plotting:
plot(my_datax, my_datay, '-*')
Change the plot to:
plot(my_datax, my_datay, '-')
to plot the line without the markers.

9 Comments

Stefano
Stefano on 30 Jul 2014
Edited: Stefano on 30 Jul 2014
Thank you, I Think that my problem is relative to the order of the data. Plot without the markers:
You have two options that I can think of:
1. Plot the values as markers only rather than as lines or markers and lines:
plot(my_datax, my_datay, '.')
Choose whatever marker you like.
2. Put your two data arrays as column vectors or column-major matrices, then use sort.
Here is an example:
t1 = rand(10,1); % Create random data for ‘t1’
a1 = rand(10,2); % Create random data for ‘a1’
[t2,I] = sort(t1); % Sort ‘t1’ as ‘t2’, save indices
a2 = a1(I,:); % Sort ‘a1’ by ‘t2’ indices to create ‘a2’
figure(1) % Plot original data
plot(t1, a1)
figure(2) % Plot sorted data
plot(t2, a2)
In your application, it would sort the data by my_datax ‘t1’ here — then uses the indices to sort my_datay, keeping the relationships of both the same. Nothing changes except the order of the data in the matrices.
Thank you very much for you answer. I followed your instructions and now I have this situation:
My pleasure.
I am not certain what you want to to with your data. It might be best to simply plot it as markers rather than lines. It will look better, and if you want to fit it to a function (curve fitting and parameter estimation), you can use that fit as a solid line and keep your data as simple markers. The nature of data is that they are uncertain, so they will have noise.
Sorting the data will not affect the results of any curve fitting you want to do on it.
Do you suggest me to fit the data and than showing also this fitting line? How could I to do? Thank you so much
Star Strider
Star Strider on 30 Jul 2014
Edited: Star Strider on 30 Jul 2014
My pleasure!
It might help you to understand your data if you can fit it to a model that you know describes the process that generated the data. That would be my preference. That is relatively easy to do in MATLAB.
If you simply want to fit your data to a line, you can use polyfit, then polyval. A third-order polynomial would likely be sufficient to fit it.
You would of course need to fit each line separately.
I do not understand what is "relatively easy to do in MATLAB". I know the model that describe my data and its response
See my attached demo of polyfit and I think you'll easily be able to see how you can adapt it to your data.
Stefano — If you know the model, I can help you do the nonlinear parameter estimation to characterise your data. That is easiest if you have the Statistics Toolbox or the Optimization Toolbox, but is only slightly more difficult using fminsearch. If you post your model and attach at least one of your data sets (so I can test my code), we can work together on coding it and then doing the parameter estimation. You will probably have to explain the model to me if it is not in an area of my expertise, but unless it is an extremely complicated model, coding and estimating it should not be difficult.
IA — Thank you. That seems to be a well-received demo.

Sign in to comment.

Joseph Cheng
Joseph Cheng on 30 Jul 2014
Edited: Joseph Cheng on 30 Jul 2014

0 votes

Depending on what you're trying to display (no labeled axes) perhaps using sort() or sortrows() to order the data in relation to x-axis data. This way there shouldn't be any back tracing in the plot.
Additionally sorting should help if you're looking at the "double" curve line for the cyan. After sorting you should be able to pick the max point of a rolling window. Sort of how a convolution would scan across the data and take the average but instead take the maximum/minimum/median/etc to get the desired curve. If these points under the curve occur at the same points that are above them you could also filter them out by finding the repeated x-axis points and use the maximum y values for the repeated points.

Categories

Tags

Asked:

on 30 Jul 2014

Commented:

on 30 Jul 2014

Community Treasure Hunt

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

Start Hunting!