フィルターのクリア

read coordinate from a txt file

5 ビュー (過去 30 日間)
burcu bilgic
burcu bilgic 2020 年 3 月 18 日
コメント済み: burcu bilgic 2020 年 3 月 18 日
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.

採用された回答

dpb
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.
  1 件のコメント
burcu bilgic
burcu bilgic 2020 年 3 月 18 日
thank you so much, now I can have my coordinates properly. is there anyway to rearrangethem into the cell format. bc I used them as controlpoints = cell(3,3); format to sent to another function which includes loops inside, now it gives a syntax error like this
Error in Main>BezierSurface (line 48)
X(:,:,k)=Bin.*Bjm.*controlpoints{i+1,j+1}(1);
Error in Main (line 22)
[Xout,Yout,Zout] = BezierSurface(controlpoints,Udirec,Vdirec);

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeVisual Exploration についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by