Home > Matlab > Matlab: import data to workspace from files via variables

Matlab: import data to workspace from files via variables

Situation is following. You have several data files and you need to import them to your workspace in cycle. Bear in mind function eval()

Solution is :

clc; clear all;
FOLDER=’DataFolder/’;
NAME1='<filename1_part1>’;
NAME2='<filename2_part1>”;
NAME3=<filename3_part1>”;

STAT1='<filename_universal_part2>’;
ENDING=’.mat’;

case1= [NAME1 STAT1 ENDING];
case2= [NAME2 STAT1 ENDING];
case3= [NAME3 STAT1 ENDING];

for  i=[1:1:3]
load([FOLDER eval([‘case’ int2str(i)])])
end

Advertisements
Categories: Matlab
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: