how to save coordinates in a text file?
Show older comments
I've used ''inpolygon'' function and I want to save the red points in a txt file in form of 2 columns of x and y, for ex. :
-1.21 3.24
-1.56 3.52
how can I do that? I'm new to matlab :D
The inpolygon function:
B=readmatrix('points.txt');
xv=B(:,1)';yv=B(:,2)';
p=readmatrix('points1.txt');
xq=p(:,1)';yq=p(:,2)';
[in,on] = inpolygon(xq,yq,xv,yv);

3 Comments
Rik
on 15 Sep 2022
You want to write numbers to a text file. You just used readmatrix to read numbers from a text file. If you were guessing instead of googling (or looking at the related functions listed at the bottom of the documentation page), what would your first try for a function be?
youssef hany
on 17 Sep 2022
Edited: youssef hany
on 17 Sep 2022
William Rose
on 17 Sep 2022
@youssef hany, @Rik is offering a hint which sounds good to me. You said "that's not what I want", but since you want to "save the filtered points in a text file", @Rik is right (as usual).
Accepted Answer
More Answers (0)
Categories
Find more on Spreadsheets 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!