Need help with import variables with readtable Function
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Choose and Parameterize Blocks finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!