MATLAB Answers

Plotting doubt: making a curve with points

Asked by Andoni Mendialdua on 22 Aug 2014
Latest activity Answered by Star Strider
on 22 Aug 2014

Hi all, I have the following code:

axis([-10 80 0 1])

I want to make a curve, but Matlab is doing lot of lines between the points. What I want to obtain is a unique curve that put together all the points.

I would be glad if you could help me:)


Michael Haderlein
on 22 Aug 2014

what's the size of COPlin and AATew?

Andrew Reibold
on 22 Aug 2014

Not enough information. You could model with a polynomial but we couldn't possibly guess at what order it needs to be. You could model with moving line average curve smoothing but we have no idea the size of these arrays or their features/values to know what would work. You could try interpolation but we again dont know enough about your problem to know what would be best.



No products are associated with this question.

1 Answer

Answer by Star Strider
on 22 Aug 2014
 Accepted answer

I am not exactly certain what the problem is, but if my guess is correct, the sort function may be the solution:

AATnew = randi(90,20,1)-10;         % ‘AATnew’ is a (20x1) array
COPlin = rand(20,1);                % ‘COPlin’ is a (20x1) array
[Ms,Mi] = sort(AATnew);             % Sort ‘AATnew’, keeping indices
plot(AATnew,COPlin,'-*')            % Plot Original UNSORTED data
plot(AATnew(Mi),COPlin(Mi),'-*')    % Plot SORTED data


Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply today