954,523 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Matlab loading file problem

Hi to all,
I want to ask how can I load files with for loop?
My file names are like D1,D2,D3 and so on..

THen how do i assign the filename variable so that Matlab recognises it?

I tried using this code but it seemed that Matlab recognised the a as the teh word "D1" rather than the file D1 and it says ndex exceeds matrix dimensions

for n=1:20
% read data file
load (['C:\weatherdata\D',num2str(n),'.txt']);
a = ['D',num2str(n)]
lati = a(5,: );

Thanks

jubleebow
Newbie Poster
9 posts since Jun 2006
Reputation Points: 10
Solved Threads: 0
 

Create the filename as a string value and use the string instead to open the file.

WaltP
Posting Sage w/ dash of thyme
Moderator
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You