Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a main script in MATLAB to accomplish the following: 1. Using the csvread

ID: 3831275 • Letter: W

Question

Write a main script in MATLAB to accomplish the following:

1. Using the csvread function, read the data contained in the provided .csv file into a variable. More information about the csvread function can be found here (http://www.mathworks.com/help/matlab/ref/csvread.html)

This is the csv file as from excel:

36.476 34.158 50.116 68.574 72.789 76.308 51.871 74.82 70.746 32.493 34.917 59.122 77.239 78.792 53.578 72.818 56.349 73.994 53.087 39.092 68.239 63.54 44.925 67.309 54.112 37.025 57.294 72.98 51.05 65.724 57.772 57.15 74.989 74.712 32.204 31.519 72.813 51.053 56.18 46.904 53.396 30.705 73.993 77.158 31.381 34.603 63.961 72.315 32.985 40.893 68.918 64.336 67.66 59.21 32.841 44.941 72.974 73.041 61.144 34.769 46.074 74.958 31.201 77.969 50.403 62.902 33.849 33.468 66.689 65.002 48.679 59.287 65.198 47.024 53.326 41.555 47.628 70.323 74.997 54.557 68.767 53.101 74.482 53.711 43.939 51.859 40.726 41.085 38.708 49.081 36.906 54.905 56.372 59.671 60.07 56.205 43.913 60.386 71.315 35.482 71.751 48.968 48.992 63.995 40.95 66.431 58.384 55.39 54.372 66.25 59.259 69.481 36.01 46.988 77.4 79.56 51.889 53.47 73.234 78.983 57.865 56.112 56.715 74.393 72.833 41.473 60.371 63.384 69.959 38.89 44.367 32.982 56.197 44.012 50.688 50.998 49.95 72.534 51.671 42.653 72.147 49.216 34.278 59.418 62.401 32.478 65.305 38.545 43.436 76.272 79.262 55.137 41.994 52.009 57.928 67.065 75.853 74.94 64.785 33.369 51.672 51.668 44.16 71.568 49.963 79.334 66.951 60.438 36.272 59.883 37.84 75.089 33.522 67.91 76.95 61.395 74.42 42.209 36.988 62.673 31.742 64.882 68.61 58.372 42.687 36.614 53.97 46.302 50.976 72.367 74.352 70.772 52.519 41.658 51.448 67.596 54.483 67.892 40.184 53.768 78.439 36.631 73.524 74.927 45.703 47.906 63.994 33.44 30.068 53.681 73.08 30.509 42.089 78.643 77.856 63.316 64.045 71.225 57.25 60.148 76.735 74.725 54.449 36.833 39.176 30.155 77.485 65.587 60.441 62.523 67.424 47.144 52.153 50.847 77.98 71.39 43.265 70.894 42.351 42.798 72.92 66.854 34.373 34.175 73.641 77.899 72.869 58.392 61.912 51.665 49.007 62.317 71.85 73.24 65.445 45.534 76.458 39.992 64.836 43.036 43.991 76.9 34.772 34.219 44.948 47.15 38.762 40.664 48.979 71.667 32.905 67.161 50.443 53.338 60.367 68.85 31.14 52.35 36.984 31.78 78.604 42.805 40.824 39.66 49.147 53.829 40.186 52.888 74.985 65.401 42.7 57.152 55.095 51.204 59.379 49.695 74.312 31.573 74.328 69.31 60.821 31.483 75.594 57.221 66.11 33.262 37.182 51.561 38.116 51.275 47.053 73.882 79.028 42.347 71.77 52.34 66.154 43.451 53.616 30.743 73.747 46.95 46.796 73.566 65.127 30.283 60.562 57.068 53.455 62.24 30.446 71.786 70.799 43.942 57.984 46.669 37.835 36.05 50.061 30.217

%% filename = 'projectInput.dat';

%% MM = csvread(filename);

2. Save the variable into a projectDAT.dat file. Important note: round the values before saving the variable (i.e., the variable will have only integers).

%% Y = round(MM)

   %% save projectDat.dat Y -ascii

3. Load the .dat file. (This step will create a variable, name projectDAT)

%% load projectDat.dat

4. Create and include a function to take the projectDAT variable as a parameter. In this function, you will use loops to compute the sum the elements of each row in order to create column vector. Allocate the size of the column vector containing the sum of each row. The column vector will be the output of this function.

5. Create and include another function to take the projectDAT as a parameter. In this function, you will use loops to compute the sum the elements of each column in order to create row vector. Allocate the size of the row vector containing the sum of each column. The row vector will be the output of this function.

6. Create and include a plot function that takes the column and row vectors as input parameters. Use the information contained in the column vector to generate a “line plot”. Additionally, use the information contained in the row vector to generate a “bar plot”. Each plot should include a “legend”, “xlabel”, “ylabel”, and a “title”.

7. Use the subplot function to display the two plots in just one figure window. The subplot figure window should have the 2 figures allocated as a “2 rows - 1 column” configuration.

8. Save the column vector and the row vector into to two separate .csv files using the csvwrite function. More information about csvwrite can be found here (http://www.mathworks.com/help/matlab/ref/csvwrite.html)

9. Use code cell to break your main script into different sections and publish it in HTML format.

Minor (10 points) In this part, you will create an algorithm (set of instructions) to re-organize the row vector (created in point number 5) as a 4x5 matrix. Note: the elements of this matrix should be filled column wise (i.e., the algorithm will start filling from left to right, then from top to bottom). Similarly, you will create an algorithm (set of instructions) to re-organize the column vector (created in point number 4) as a 5x4 matrix. Note: the elements of this matrix should be filled row wise (i.e., the algorithm will start filling from top to bottom, then from left to right). Save the two matrices into two separate .csv files.

Explanation / Answer

filename = 'projectInput.dat';
MM = csvread(filename);
Y = round(MM)
save projectDat.dat Y -ascii
load projectDat.dat

function [columnv] = rowsum(in)

rows=size(in,1);
cols=size(in,2);
columnv=zeros(rows);
sums=0;

for i=1:rows

for j=1:cols
  
sums=sums+in(rows)(cols);
end
columnv(i)=sum;
sum=0;
end

columnv = reshape(columnv,[rows,1])


end

  
function [rowv] = colsum(in)

rows=size(in,1);
cols=size(in,2);
rowv=zeros(cols);
sums=0;

for i=1:cols

for j=1:rows
  
sums=sums+in(rows)(cols);
end
rowv(i)=sum;
sum=0;
end


end


function [] = colsum(columnv,rowv)

rows=[1:size(columnv,1)];
col=[1:size(rowv,2)];

columnv=reshape(columnv,[1,size(columnv,2)]);
plot(rows, columnv), xlabel('rows'), ylabel('row sums'), title('row sum');
end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote