- #1
blizzard12345
- 14
- 0
hi i want to load multiple sets of data in a loop and the plot a linear graph each time the loop runs below is my code so far, i can't seem to load any variable from the file names, the variable are for example int_force=[1;2;3;4;5] deflection=[1;2;3;4;5]
function load_data
clear all
clc
%determins the number of saved files in directory
graph = dir('internalforce_*');
k = size(graph);
%starts a loop to load increase values of eg, internalforce_1,
%internalforce_2...
for i = 1 : k(1)
file_name = sprintf('internalforce_%d',i)
variable = load(file_name,'int_force')
file2_name = sprintf('deflection_%d',i)
variabletwo = load(file2_name,'deflection')
plot(variable,variabletwo)
hold on
end
end
function load_data
clear all
clc
%determins the number of saved files in directory
graph = dir('internalforce_*');
k = size(graph);
%starts a loop to load increase values of eg, internalforce_1,
%internalforce_2...
for i = 1 : k(1)
file_name = sprintf('internalforce_%d',i)
variable = load(file_name,'int_force')
file2_name = sprintf('deflection_%d',i)
variabletwo = load(file2_name,'deflection')
plot(variable,variabletwo)
hold on
end
end