I have several external files that I read in using readmatrix(). so:
one=readmatrix();
two=readmatrix();
three=readmatrix();
I then put them into an array,
A=[one two three]
Now how can I make the program choose one of those files randomly, I tried:
x=A(randi(length(A),1))
But then it chooses random elements of those files, so how can I make it choose a file itself so that I can use if x==one ....
Please note im really new to coding and this is my first project.
CodePudding user response:
When you do A=[one two three]
you concatenate the 3 matrices rather than create a list of 3 elements.
One way to achieve what you want is to use cell arrays:
A = {one, two, three}
Now A
is a cell array with 3 elements that you can choose randomly.