load multiple files in a loop

11 ビュー (過去 30 日間)
kyle lyth
kyle lyth 2011 年 5 月 6 日
Hi everyone, i have another piece of code that saves one variable into a step increasing file name eg file_1,file_2 each time the code is run. i know need to try and load the data in a loop and be able to plot it onto a graph for comparison.
any help would be greatly appreciated thank kyle :) (below is a copy of the code i have so far)
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)
variable(i) = load('internalforce_(i)')
end
end

採用された回答

Paulo Silva
Paulo Silva 2011 年 5 月 6 日
for i = 1 : k(1)
variable(i) = load(sprintf('internalforce_%d',i))
end
  2 件のコメント
kyle lyth
kyle lyth 2011 年 5 月 6 日
hi ive alterd my code, but with this it shows variable(i) to be
variable =
int_force: [11x1 double]
and to be completely honest i have no idea what this means, if you could explain a little for me that would be great
Paulo Silva
Paulo Silva 2011 年 5 月 6 日
Do this command after loading the files
class(int_force)
you will see what class of variable it is, now put doc before the name of the class and read the documentation about it.

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2011 年 5 月 6 日
Please see the FAQ on this topic, and also this FAQ

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by