Need help with import variables with readtable Function
조회 수: 3 (최근 30일)
이전 댓글 표시
I am currently trying to create a code that imports 3 .csv files. The problem that i am having is that anything past the first table the code does not keep the variables and changes them to VarX. Has anyone experienced this before? How did you fix it other than having to rename the variables. The error that i get is Unrecognized variable name 'pt1_X'. Thank you in advanced.
%Set variables
u = symunit;
%Rod diameter
n=9.7 * u.mm;
% read table
%XYZ of Cockroach
[file, path] = uigetfile('*.csv');
tbl = readtable([path file]);
%XYZ of Rod
[file, path] = uigetfile('*.csv');
tbl2 = readtable([path file]);
%get rod points and remove NaN from table
tbl2([1:150],:) = [];
tbl2([11:end],:) = [];
%{
%XYZ of Gravity refernce
[file, path] = uigetfile('*.csv');
tbl3 = readtable([path file]);
%get gravity points and remove NaN from table
tbl3([1:150],:) = [];
tbl3([11:end],:) = [];
%}
% plot all points, blue is the head
figure
plot3(tbl.pt1_X, tbl.pt1_Y, tbl.pt1_Z, 'b.')
hold on
plot3(tbl.pt2_X, tbl.pt2_Y, tbl.pt2_Z, 'r.')
%Plot rod
plot3(tbl2.pt1_X, tbl2.pt1_Y, tbl2.pt1_Z, 'kx')
hold on
plot3(tbl2.pt2_X, tbl2.pt2_Y, tbl2.pt2_Z, 'kx')
hold on
plot3(tbl2.pt3_X, tbl2.pt3_Y, tbl2.pt3_Z, 'kx')
hold on
plot3(tbl2.pt4_X, tbl2.pt4_Y, tbl2.pt4_Z, 'kx')
hold on
plot3(tbl2.pt5_X, tbl2.pt5_Y, tbl2.pt5_Z, 'kx')
hold on
plot3(tbl2.pt6_X, tbl2.pt6_Y, tbl2.pt6_Z, 'kx')
hold on
댓글 수: 3
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!