Matlab Question 5. Suppose you have a file called sample.dat that resides in you
ID: 3695264 • Letter: M
Question
Matlab Question
5. Suppose you have a file called sample.dat that resides in your working directory in MATLAB and has four rows and four columns exactly as shown below (you may wish create this file during the exam): 4.001 a MMM -200 . 10908 300.00005 8.102 CCETCET 70.50000 -6.12300 4.001 -29.001 b Z 15.00 dddd CAE In the space below write down no more than five MATLAB commands that do the following: (a) open the file (b) read the two numerical columns into a 4x2 matrix, (c) read the two text columns into two 4x1 cell arrays.Explanation / Answer
fid=fopen('sample.dat','r');
A=textscan(fid,'%f%s%s%f');
N=csvread('sample.dat',1,3);
M=csvread('sample.dat',0,4);