Question: using matlab fix the following what needs fixed is my else statement the program is to do the following the dice is rolled and populates

using matlab fix the following what needs fixed is my else statement

the program is to do the following

the dice is rolled and populates an array the same number cant be in the array more then once the dice will keep rolling till 260 number out of 310 is in the array with no copys of the same number if the number rolled isn't found in the array the else statement is to be then executed saving the number into a table as show for some reason my else statement isn't executing if the number rolled wasn't found in the array hence executing the else statement

T = readtable('Biomechanical_Data_2Classes.csv');

disp(T(1,1:7));

N=0;

roll= 230;

arrayrand=[];

arrayrandnot=[];

trainingdata=[];

starttrainingdata=[];

k=0;

p=0;

for k = 1:roll

numbroll = ceil(310*rand);

arrayrand(k) = numbroll;

if find(arrayrand == numbroll) % find function is used in case of numeric vectors

disp("matches"+numbroll)

k=k-1;

else

starttrainingdata = T(numbroll, 1:7);

Tnew = [T;starttrainingdata];

p=p+1;

% k=k+1 <-- You don't need to do that in for loop

end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!