1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kirill115 [55]
3 years ago
14

Given an input array of strings (characters) s, pick out the second column of data and convert it into a column vector of data.

Missing data will be indicated by the number 9999. If you encounter missing data, you should set it to the average of the immediately neighboring values. (This is a bit simpler than using `interp1`.)
If the input array is s = [ 'A' '0096' ; 'B' '0114' ; 'C' '9999' ; 'D' '0105' ; 'E' '0112' ]; then the output variable `t` is the following column vector. t = [96 114 109.5 105 112]';
Compose a function read_and_interp which accepts an array in the above format and returns the data converted as specified. You may find the conversion function `str2num` to be useful.
(Using MATLAB Syntax only)
Computers and Technology
1 answer:
hodyreva [135]3 years ago
7 0

Answer:

Consider the following code.

Explanation:

save the following code in read_and_interp.m

 

function X = read_and_interp(s)

[m, n] = size(s);

X = zeros(m, 1);

for i = 1:m

if(str2num(s(i, 2:5)) == 9999)

% compute value based on previous and next entries in s array

% s(i, 2:5) retrieves columns 2-5 in ith row

X(i,1) = (str2num(s(i-1 ,2:5)) + str2num(s(i+1,2:5)))/2;

else

X(i,1) = str2num(s(i,2:5));

end

end

end

======================

Now you can use teh function as shown below

s = [ 'A' '0096' ; 'B' '0114' ; 'C' '9999' ; 'D' '0105' ; 'E' '0112' ];

read_and_interp(s)

output

ans =

96.000

114.000

109.500

105.000

112.000

You might be interested in
Explain with examples: <br> What are the reasons of a successful and unsuccessful software project?
Darina [25.2K]

Answer:

A good starting point is by addressing some of the key reasons software projects fail.

Explanation:

Not Enough Time. ...

Insufficient Budget. ...

Poor Communication. ...

Never Reviewing Project Progress. ...

Inadequate Testing. ...

Testing in the Production Environment. ...

Lack of Quality Assurance. ...

Not Conforming to Industry Standards.

6 0
3 years ago
NWhen you measure a person’s weight, you are measuring the
MAVERICK [17]

Answer:

gravitational force acting on that person.

Explanation:

5 0
3 years ago
Read 2 more answers
A(n)___ is divided into rows and columns.<br> What goes in the blank?
Ber [7]
A spreadsheet consists of rows and colums
8 0
3 years ago
What are some advantages and disadvantages to flooded coolers?
aliya0001 [1]
Advantage is that the refrigerant distrubing in the evaporator will reduce and disadvantage is that the distribution of evaporator will increase
5 0
4 years ago
In the 2007/2010 version of Paint, which of the following tools are located in the View tab? (Select all that apply.)
zaharov [31]
The answers are full screen and gridlines.
7 0
4 years ago
Other questions:
  • A beginning driver may tend to oversteer. This means the driver what? Btw Cars are technology so that is why it is under Compute
    11·1 answer
  • Which type of address is used at the transport layer to identify the receiving application?
    14·1 answer
  • M
    15·1 answer
  • which is the quickest way to change the font color in multiple, randomly located cells in a worksheet?
    6·2 answers
  • What type of data is not defined and does not follow a specified format and is typically free-form text such as emails, Twitter
    13·1 answer
  • Does anyone know what happened to Cole Morgen, the actor?
    11·1 answer
  • Create a simple self-checkout system. Prompt for the prices and quantities of three items. Calculate the subtotal of the items.
    15·1 answer
  • A collection of computers, printers, routers, switches, and other devices
    15·1 answer
  • Match each item with a statement below. - A popular port scanners that has the ability to use a GUI front end - Allows you to pi
    8·1 answer
  • Select the best answer from the drop-down menu.
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!