read coordinate from a txt file
11 ビュー (過去 30 日間)
古いコメントを表示
hi, I am working on a bezier surface plotting and I need to read my control points coordinates from a txt file which looks like this:
0.0, 20.0, 3.87
1.3, 30.2, 56,7
7.2, 98.0, 32.5
in the end I need to have somethink like the following but these control points should be in a txt file.
controlpoints=cell(3,3);
controlpoints{1,1}=[ 0.0, 0.0, 65.0];
controlpoints{1,2}=[ 0.0, 76.2, 100.0];
controlpoints{1,3}=[ 0.0, 152.4, 85.0];
controlpoints{2,1}=[ 50.8, 0.0, 50.0];
controlpoints{2,2}=[ 50.8, 76.2, 95.0];
controlpoints{2,3}=[ 50.8, 152.4, 65.0];
controlpoints{3,1}=[ 101.6, 0.0, 85.0];
controlpoints{3,2}=[ 101.6, 76.2, 70.0];
controlpoints{3,3}=[ 101.6, 152.4, 85.0];
I tried to use textscan function but it doesnt work for some reasons.
0 件のコメント
採用された回答
dpb
2020 年 3 月 18 日
textscan is overkill for a simple csv file of the above form --
controlpoints=importdata('YOURTEXTFILE.CSV');
and you'll have the input data as a double array, without the nuicsance of cell array to dereference--far superior.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Large Files and Big Data についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!