Load file with certain number
Show older comments
Dear all,
I'm writing a program in Matlab, where all data is first loaded from the file '20.mat'. Then I create a vector with all 20's, to remember the data in that column is from the film '20.mat'. After some scripts, I want to replace one of these column with data from a file-number lower. So for example:
First: A=[20 20 20 20 20]
Replacing place: 4
Load data with number from A(4)-1 = 19, and replace column 4 with the data from column 4 of '19.mat'.
The problem however is that I don't know beforehand with number I have to load, because if in the next step the replacing place is 1, I again need to load data from '19.mat', but if I again have to replace place 4, I have to load '18.mat'. I could write an if-loop for all separate cases, but because there are quite a lot of cases, I was wondering if there is a direct way to do this. Something like load('r.mat'), where r=A(4)-1.
Kind regards, Marjolein
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB Report Generator in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!