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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started