Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MATLAB Prepare a function m-file containing a function that prints a line (to the command window), where the line consists of a string and the

MATLAB

Prepare a function m-file containing a function that prints a line (to the command window), where the line consists of a string and the values of the elements in a vector. All these components should print on one line with white space between the different components.

The input will be a structure. The first field will contain the string. The second field will contain the vector of length 4 and of class double. There will be no output variables.

In the third section of your script m-file, generate a structure array having 2 component structures. You can use any values you want. You will call your function twice. The first time, you will use the first component structure as input. The second time, you will use the second component structure as input.

The help I need is with the third section, I have the function below, and am having a hard time calling it, (and then calling it again), please show me how to properly call this function (also I'm getting an error on the vec2, saying it's unused, is this still okay/correct?):

function[str] = makestructs(vec1,vec2) str = struct([]); for i=1:length(vec1) str(i).name = vec1(i); str(i).marks = marks(i); end end

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started