- x and y shall be column vectors
- x and y shall be of equal length
Is there a way in MATLAB to make a boundary and have it skip over data pairs?
3 views (last 30 days)
Show older comments
Hannah Bercovici
on 31 Jul 2018
Commented: Hannah Bercovici
on 1 Aug 2018
I am attempting to make a boundary out of data that is somewhat incomplete. I have been replacing the NaN with 0's, but then the boundary shows up on my graph covering an area I suspect is not accurate. Is there a loop that would allow MATLAB to read the data and make a boundary only out of pairs of data that do not include NaN?
For example, if the data sets are:
m = [0 NaN 2 3 5 NaN]
a = [NaN 2 3 4 5]
I would want to make it so that if I were to make a boundary
am_boundary = boundary(a, m);
then I could use an if loop or something else to only make the boundary out of the third, fourth and fifth data pairs.
Thanks!
0 Comments
Accepted Answer
per isakson
on 1 Aug 2018
Edited: per isakson
on 1 Aug 2018
Documentation of the function, boundary(x,y), says
Try
%%equal length
m = [0 NaN 2 3 5 NaN];
a = [NaN 2 3 4 5, nan ];
%%column vectors
m = reshape( m, [], 1 );
a = reshape( a, [], 1 );
ixnonan = find( not(isnan(m)|isnan(a)) );
k = boundary( a(ixnonan), m(ixnonan) );
k = [ ixnonan(k(1:end-1)); ixnonan(k(1)) ];
am_boundary = [ a(k), m(k) ];
plot( m, a, 'd' )
hold on
plot( m(k), a(k) )
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!