Question

Matlab!

Use Matlab to calculate array X and array Y. The first column is time (1, 2, 3 ...), and the second column is value (0 and 1).
When the value of array X is 0, the value of array Y is itself at the same time.
When the value of array X is 1, the value of array Y will become the value of the previous Y(i-1)

The data of the array is given, just how to change the value of Y at the corresponding time according to the value of X

Save the new results in a new array

2 92133x2 double 1 ou A WN 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17

0 0
Add a comment Improve this question Transcribed image text
Answer #1

%   Sample data for testing
Data = [[1:50]' randi([0 1],50,1)];

%   Getting X and Y calculated
X = Data(:, 2);
Y = Data(:, 1);

%   Setting Y for X = 0
idx_0 = find(X==0);
Y(idx_0) = Y(idx_0)
%   Setting Y for X = 1
idx_1 = find(X==1);
Y(idx_1) = Y(idx_1-1)

LIVE EDITOR INSERT VIEW % en MY Code Task Control - 4x Refactor - CODE Run Step Aa Normal -> Go To 4 BIUM Find - Text EE NAVI

LIVE EDITOR INSERT VIEW Task Go To Find Aa Normal - Text BIUM - Run Step Stop Control - A Refactor - CODE Section E Break SEC

Note: For queries, drop me a comment.

Add a comment
Know the answer?
Add Answer to:
Matlab! Use Matlab to calculate array X and array Y. The first column is time (1,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • matlab help Write a script to manipulate the array A = [2 1 4 3 6...

    matlab help Write a script to manipulate the array A = [2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19] to be in descending order without using the sort function. You must do everything using array manipulation in MATLAB (i.e. you cannot sort it by hand and then hardcode it, you cannot simply create the array 1:20, you cannot simply add .rej3mat(J-l 1],1,10) to A). Write a script that...

  • array : .word 300   # Attempt to initialize array lw $15, 8                 # num = 8...

    array : .word 300   # Attempt to initialize array lw $15, 8                 # num = 8 lw $17, array          # Place array in register 17 lw $16, 0                 # sum = 0 lw $14, 2                 # subtraction value whileLoop: blt $15, $zero exitLoop     # $zero always holds the constant 0, while (num >= 0) add $16, $16, $15 # sum += num sub $15, $15, $14       # num -= 2 j whileLoop exitLoop: sw $16, 12($17)      # array[3] = sum...

  • Given the following array of integers (of capacity 20) with 12 items: 0 1 2 3...

    Given the following array of integers (of capacity 20) with 12 items: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 8 4 10 15 5 7 11 3 9 13 1 6             Index of last element = 11 Does this array represent a min heap? If not, convert it to a min heap (i.e., “heapify” it). Please show all steps.

  • MATLAB Any guidance is appreciated! Use meshgrid() function to create 2D grid coordinates with x- and...

    MATLAB Any guidance is appreciated! Use meshgrid() function to create 2D grid coordinates with x- and y- coordinates both from -12 to +12 in the increment 1/32. B) Calculate the function z shown below at every (x, y) point and store the result in a 2D array z Z = sin(squareroot x^2 + y^2)/ squareroot x^2 + y^2 c) Find the maximum value in array z and its corresponding index. The array may have more than one maximum points with...

  • Using Matlab Background: Work through Matlab Exercise 2 (posted with this assignment). Steps #8 and #9 pertain to th...

    Using Matlab Background: Work through Matlab Exercise 2 (posted with this assignment). Steps #8 and #9 pertain to this problem. Consider the following sample of ordered pairs (x. y) where y = the purity of oxygen produced in a chemical distillation process, and x the percentage of hydrocarbons that are present in the main condenser of the distillation unit Hydrocarbon Level; x (in %) Purity y (in %) Observation Hydrocarbon Observation Purity Level; x (in %) y (in % )...

  • Create a 1000 x 4 matrix, with the first column switching between 0,1 (starting with 1), and the ...

    Solve using Matlab. Provide actual code. Create a 1000 x 4 matrix, with the first column switching between 0,1 (starting with 1), and the second column repeating itself in cycles of 1-2-3-4-5, the third column consisting of only 4's and the fourth column repeating itself in cycles of 0-1-2-3 Create a 1000 x 4 matrix, with the first column switching between 0,1 (starting with 1), and the second column repeating itself in cycles of 1-2-3-4-5, the third column consisting of...

  • Create 4 arrays: a 1-D array to store the students’ id, 1-D array to store the...

    Create 4 arrays: a 1-D array to store the students’ id, 1-D array to store the students’ names, a parallel 2-D array to store the test scores, and a parallel 1-D array to store letter grades. Read data into the 3 arrays from the file data121.txt. If the file is not found, the program needs to terminate with this error, “Data file not found.”            Calculate and store a letter grade into a 1-D array based on the total score,...

  • Create 4 arrays: a 1-D array to store the students’ id, 1-D array to store the...

    Create 4 arrays: a 1-D array to store the students’ id, 1-D array to store the students’ names, a parallel 2-D array to store the test scores, and a parallel 1-D array to store letter grades. Read data into the 3 arrays from the file data121.txt. If the file is not found, the program needs to terminate with this error, “Data file not found.” Calculate and store a letter grade into a 1-D array based on the total score, sum...

  • write a Matlab program ( solve the three questions). please use array and create your own...

    write a Matlab program ( solve the three questions). please use array and create your own function to check primality Question 1 : [10 points) Write a MATLAB program that will store all the first 1000 prime numbers in an array variable named arr_of_primes. Please note that a prime number is a positive integer that is bigger than or equal to 2 which is divisible only by 1 and itself. Examples of the first 8 primes are: 2, 3, 5,...

  • 1. Write a Matlab function to convolve two sequences objects: function y = conv(x, h) %...

    1. Write a Matlab function to convolve two sequences objects: function y = conv(x, h) % CONV Convolve two finite-length Matlab sequence objects, x and h % returning sequence object, y. When you convolve x[n] and h[n] , you may not use MATLAB's numerical conv routine. 2. write a second convolution function, conv_rt, in Matlab that basically implements a real-time convolu- tion strategy: function y = conv_rt(x, h) % Convolve two finite-length arrays, x and h % returning array, y...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT