Q 13.1 Given three vectors:
n = [50 40 60]
class ={ 'grade one' 'grade two' 'grade three'}
score = [ 66.7 69.8 70.25]
Apply strcat() to create the following three strings all together :
There are 50 students in the grade one, the average score is 66.70
There are 40 students in the grade two, the average score is 69.80
There are 60 students in the grade three, the average score is 70.25
Note: Do not use sprintf(), do not use loop. You may need num2str() and strsplit().
I need help to solve this in MATLAB programming...
MATLAB CODE:-
n = [50 40 60];
nn = num2str(n);
C = strsplit(nn);
class ={ 'grade one' 'grade two' 'grade three'};
score = [66.7, 69.8 ,70.25] ;
ss = num2str(score);
Cc = strsplit(ss);
s = strcat({' There are ' } , C ,{ ' students in ' } , class , { '
the average score is ' } , Cc)
screenshot of code and result:-
kindly like if you find it needfull..please comment for further elaboration
Get Answers For Free
Most questions answered within 1 hours.