How to extract data from ".asc" files in MATLAB??
137 views (last 30 days)
Show older comments
Hi,
In my work I have to scan any object from fringe projector and then I will have a '.asc' file with 6 columns. I am assuming first column refers to x, second to y and 3rd to z-axis (height) and 4,5 and 6th columns are again x, y and z-axis. It's a huge data, Now I want to import this data into MATLAB and plot it (x,y,and z information). Could any body help me how can I do that. I am showing the data below: (this is not complete data, original data is huge)
-37.097786 -52.725983 350.510498 0.223211 0.007616 -0.974741
-36.947704 -52.728733 350.531799 0.007486 -0.035378 -0.999346
-36.793694 -52.728699 350.531616 -0.090732 0.022629 -0.995618
-36.639324 -52.727188 350.520966 -0.015493 0.097718 -0.995094
-36.488319 -52.725441 350.508545 -0.031563 0.058234 -0.997804
-36.332428 -52.723324 350.521240 0.028490 0.078162 -0.996534
-35.264877 -52.718163 350.520294 -0.021093 0.058220 -0.998081
-35.112240 -52.718128 350.520142 -0.079015 0.075934 -0.993977
-34.960155 -52.718109 350.506958 -0.059120 0.113363 -0.991793
-34.804401 -52.714741 350.506836 -0.005345 0.129367 -0.991582
-34.653065 -52.713692 350.506897 0.017085 0.132164 -0.991081
-34.500076 -52.713673 350.509155 -0.073305 0.122992 -0.989697
-34.346672 -52.711987 350.502502 -0.007277 0.193650 -0.981044
-34.193836 -52.711224 350.502625 0.054685 0.190075 -0.980245
-34.041569 -52.711155 350.501648 0.023690 0.132977 -0.990836
-33.888245 -52.709606 350.502594 0.040745 0.102349 -0.993914
-33.735741 -52.709263 350.500549 0.025765 0.049673 -0.998433
-33.583431 -52.707909 350.502563 -0.011228 0.018373 -0.999768
-32.667183 -52.704651 350.506744 0.010688 0.033379 -0.999386
-32.513115 -52.703819 350.498260 -0.160013 0.009997 -0.987064
-32.360893 -52.702785 350.498077 -0.083208 0.159371 -0.983706
-32.208809 -52.702778 350.503754 0.050479 0.261780 -0.963807
-32.057354 -52.702782 350.501404 0.052867 0.217744 -0.974573
-31.902649 -52.700027 350.492523 -0.006996 0.128643 -0.991666
-31.748346 -52.697392 350.485016 -0.065730 0.081881 -0.994472
-31.595976 -52.697353 350.482788 -0.008491 0.116529 -0.993151
-31.443119 -52.697361 350.485016 0.125159 0.123452 -0.984426
-31.292290 -52.696255 350.490112 0.033089 0.011696 -0.999384
-31.138966 -52.695351 350.490051 -0.158905 -0.004761 -0.987282
-30.986063 -52.694977 350.485931 -0.126066 0.152085 -0.980294
-29.457098 -52.687782 350.469788 -0.233680 0.251874 -0.939124
-29.307178 -52.683479 350.481323 0.200435 0.473870 -0.857481
-29.154070 -52.684864 350.482178 0.270367 0.309417 -0.911681
-29.001129 -52.683186 350.481873 -0.031573 0.035388 -0.998875
-28.850380 -52.683205 350.471313 0.041236 0.035756 -0.998509
-28.696020 -52.683186 350.480743 -0.037375 0.005525 -0.999286
-28.544468 -52.684689 350.480713 -0.088845 0.072584 -0.993397
-28.391764 -52.684662 350.475800 -0.049506 0.157649 -0.986254
-26.559263 -52.672192 350.456360 -0.238495 -0.132830 -0.962017
-26.406803 -52.672188 350.456451 0.078632 0.177892 -0.980903
-26.255188 -52.669987 350.451141 0.058778 0.088570 -0.994334
-26.101706 -52.669785 350.446503 -0.075076 0.010739 -0.997120
-37.244392 -52.564568 350.464050 0.207019 -0.131837 -0.969413
-37.097736 -52.573536 350.509430 0.175372 -0.130962 -0.975753
-36.947174 -52.574398 350.528625 0.065340 -0.106741 -0.992138
-36.793694 -52.574398 350.528717 -0.017201 -0.073352 -0.997158
-36.638435 -52.573395 350.528595 -0.052650 -0.057560 -0.996953
-36.488312 -52.572674 350.519287 -0.011898 -0.019907 -0.999731
-36.333241 -52.572666 350.521362 0.027581 -0.018667 -0.999445
-36.181942 -52.572121 350.523468 0.057835 -0.022563 -0.998071
-36.028706 -52.569538 350.523590 -0.003715 -0.065266 -0.997861
-35.875271 -52.567699 350.523438 -0.067950 -0.065882 -0.995511
Thanks,
Swati
2 Comments
Rachel Bielski
on 10 Aug 2017
I am working with a similar .asc file from 3-D Scan Control software, but I am having trouble interpreting what the last 3 columns of data mean. What do you mean by saying the 4th, 5th, and 6th columns of your data are "again" the x, y, and z axis, and how do you know this? I am new to this software and file type so any guidance would be appreciated.
Accepted Answer
KSSV
on 7 Aug 2017
Read about load and importdata...with these you can import whole data as a matrix...and then you can do what you want.
0 Comments
More Answers (1)
Jan
on 7 Aug 2017
Edited: Jan
on 7 Aug 2017
fid = fopen(FileName, 'r');
if fid == -1, error('Cannot open file: %s', FileName); end
data = fscanf(fid, '%g', [6, Inf]).';
fclose(fid);
It is not clear how you want to "plot it (x,y,and z information)".
3 Comments
Jan
on 8 Aug 2017
Why do you convert the data to an Excel file, but write in the question, that it is an .asc file? You mentioned explicitly 6 columns, now you import 3 columns only. Please do not change the problem dynamically during the discussion.
As you found out, Excel files have to be read by xlsread or readtable, while the fscanf approach works with text files only.
Why does the function plot3Ddata has x,y,z as input, but overwrite them with the imported data? What does show where and empty matrix? What is the contents of the XLSX file?
See Also
Categories
Find more on Data Import from MATLAB 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!