Also, you can see that the tables have numbers in them so I think that I should be able to make an array of the tables by doing something like this "A = BACK_2017_06_01:BACK_2017_06_nn" but it has not worked yet.
For loop that crosses different data sets.
1 次查看(过去 30 天)
显示 更早的评论
I am trying to compile the data from many sets of data (tables) into a graph. I have successfully written the code to graph each at a time but I am now trying to add a for loop so that it will do many sets at the same time. I know I will have to call my data in by hand (import each individually), but is there a way that I will be able to create a for loop that can go into different data sets to get the points and then follow the code I have now?
This is what I have now for the plotting of individual tables:
"
%call in the data
x1 = BACK_2017_06_01(:,2);
y1 = BACK_2017_06_01(:,3);
z1 = BACK_2017_06_01(:,4);
t1 = BACK_2017_06_01(:,1);
%make the tables into numeric arrays
x = table2array(x1);
y = table2array(y1);
z = table2array(z1);
t = table2array(t1);
scatter3(x1{:,1}, y1{:,1}, z1{:,1})
hold on
xlabel('X')
ylabel('Y')
zlabel('Z')
hold off
figure
% plot x, y, and z against time
plot(t,x,'r')
hold on
plot(t,z,'b')
hold on
plot(t,y,'y')
title('x vs time')
hold off
legend('x','z','y')
figure"
2 个评论
Geoff Hayes
2017-7-19
Sarah - is BACK_2017_06_01 the data from one particular table? If so, then you could create a function (out of the above code) that takes BACK_2017_06_01 (or equivalent from the other tables) as an input. Then you could call this function for as many files that you have data
function plotdata(myTableData)
%call in the data
x1 = myTableData(:,2);
y1 = myTableData(:,3);
z1 = myTableData(:,4);
t1 = myTableData(:,1);
% etc.
Though the above would create a new figure for each table input. Is this what you are looking for?
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!