MATLAB Answers

VIJAY
0

How to form a matrix ?

Asked by VIJAY
on 18 Sep 2019 at 7:44
Latest activity Edited by KALYAN ACHARJYA on 18 Sep 2019 at 8:06
name=['ajay;sekar;tom] have scor the mark1 is[20;30;40]; and also mark2 is[25;35;45]; and also mark3 is[23;33;43]; i want to display as follow
name mark1 mark2 mark3
ajay 20 25 23
sekar 30 35 33
tom 40 45 43

  1 Comment

Walter Roberson
on 18 Sep 2019 at 7:55
The easiest is to loop using fprintf() for each line.
It is possible to print it all out in one command, but the code is not as clear.

Sign in to comment.

Tags

No tags entered yet.

1 Answer

Answer by KALYAN ACHARJYA on 18 Sep 2019 at 8:03
Edited by KALYAN ACHARJYA on 18 Sep 2019 at 8:06
 Accepted Answer

name= {'Ajay';'Sekhar';'Tom'}
mark1=[20;30;40];
mark2=[25;35;45];
mark3=[23;33;43];
Varibles_Names={'Name', 'Mark1', 'Mark2', 'Mark3'};
T = table(name,mark1,mark2,mark3, 'VariableNames',Varibles_Names)
Result:
3×4 table
Name Mark1 Mark2 Mark3
________ _____ _____ _____
'Ajay' 20 25 23
'Sekhar' 30 35 33
'Tom' 40 45 43
Other way:
As suggested by @Walter using fprintf

  0 Comments

Sign in to comment.