Question

MATLAB Code please!

Integer indexing array: Reverse subsets Construct an indexing array indexArray so that the statement reversedOrder origOrder(indexArray); results in a row array beginning at starting index down to element 1 . Ex: If origOrder is 12, 8,9,15, 3, 44, 23, 25,7,68] and startingValue is 3, then reversedOrder is [9, 8,2]. Row array reversedOrder contains origOrders element 3, element 2, and element 1 Your Function Save Reset E MATLAB Documentation 1 function reversedorder-CopySubset (startingIndex, origorder) 2% start ingindex: starting index of copied subset indexArray- [1:1:1); % change index values 5 reversedorder-origorder(indexArray) 6 7 end Code to call your function C Reset 1 origorder - [2, 8, 9, 15, 3, 44, 23, 25, 7, 68]; 2 CopySubset (3, origorder)

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

Hey,

Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries

%YOUR FUNCTION

function reversedOrder= CopySubset(startingIndex,origOrder)
indexArray=[startingIndex:-1:1];
reversedOrder=origOrder(indexArray);
end

CODE TO CALL THE FUNCTION

origOrder=[2,8,9,15,3,44,23,25,7,68];
CopySubset(3,origOrder)

4origorder-12,8,9,15,3,44, 23,25,7,681: CopySubset (3,origOrder) Command Window () New to MATLAB? Watch this Video, see Examp

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
MATLAB Code please! Integer indexing array: Reverse subsets Construct an indexing array indexArray so that the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • Arithmetic array operations Add adjustVal to each element of array originalReadings. Your Functio...

    Arithmetic array operations Add adjustVal to each element of array originalReadings. Your Function Save C Reset MATLAB Documentation 1 function modifiedReadingsCalibrateReadings (originalReadings, adjustVal) 21% origina!Readings: Array of temperature readings 31% adjustval: value added to each element in the array of temperature readings 4. % Add adjustval to each element of array origina!Readings modifiedReadings e 6 7 end Code to call your function C Reset 1 CalibrateReadings([51, 53, 61, 62], 1) Indexing an array element Assign studentScore with the second element...

  • Linear-spaced points array struct a row array plotPoints with 5 values that are spaced linearly from...

    Linear-spaced points array struct a row array plotPoints with 5 values that are spaced linearly from lowValue to highValue. Hint: Use the linspace function Ex: If lowValue is 1 and highValue is 10, plotPoints is [1.0000, 3.2500, 5.5000, 7.7500, 10.0000] Your Function Save Reset叩MATLAB Documentation 1: function plotPoints-CreatePoints(lowalue, highValue) 21% lowalue: Starting value in plotPoints % highvalue: Ending value in plotPo ints % construct a row array plotPoints with 5 linear-spaced % point from 10«Value to highvalue plotPoints = 0;...

  • *****************************CODE SHOULD BE WRITTEN IN C++************************ Write a function to reverse an array of integers starting...

    *****************************CODE SHOULD BE WRITTEN IN C++************************ Write a function to reverse an array of integers starting from a given start index and a given end index. Note, the end index is inclusive. Add code to the given function below. *********************FUNCTION TO BE USED*********************************************** #include "problem1.h" void reverseArray(int arr[], int start, int end) { //written code } ************************************EXAMPLE************************************************ int[] a = {1,2,3}; reverseArray(a, 0, 2); //The content of a should be {3,2,1}. int[] a = {1,2,3}; reverseArray(a, 0, 1); //The content...

  • MatLab Help!! Write a function called Difference to calculate the central difference, forward diflerence, and backward diference approximation to an function within a given range of xmin:xinc:xmax...

    MatLab Help!! Write a function called Difference to calculate the central difference, forward diflerence, and backward diference approximation to an function within a given range of xmin:xinc:xmax The input argument of the function Difference is the handle to an anonymous function, a row array xmin:xinc:xmax The differences should be returned as a row array, calculated at xmin xinc xmax Restriction. The function should not use loops Ex func - (x) x.3 xmin-3 xinc-e.25; xmax-4; [backDifference, centralDifference, forwardDifference] Derivative(func, xmin, xmax,...

  • matlab please Problem 1. PART A Create a cell array called ca that will contain the following: [Physics] [14][1 4 -...

    matlab please Problem 1. PART A Create a cell array called ca that will contain the following: [Physics] [14][1 4 -3 8] [ITim] [Burnett]] [23] [Jessica] [Wul] [3 9 17] [Chemistry] [8 7 2 91 [Literature] [IJavier] [Lopez] [54] As shown above, the cell array ca should contain within the cells of each row: a department name (eg. Physics), integer code (e.g., 14), an array of integers (e.g., [1 4-3 8]), and two sub-cells containing a person's first and last...

  • Write a program that asks the user to input 10 integers of an array. The program...

    Write a program that asks the user to input 10 integers of an array. The program then inserts a new value at position (or index) given by the user, shifting each element right and dropping off the last element. For example, in the sample input/output below, the program will insert the value 30 at index 3. All the previous numbers of the array starting from position 3 (i.e., 7 1 20 9 23 8 22 will be shifted one position...

  • Write a function called ZeroCornersSecondRow that sets the corners of a 2D array to zero and...

    Write a function called ZeroCornersSecondRow that sets the corners of a 2D array to zero and also outputs the second row. The input arguments: • inArray: A double precision 2D array of size nxn, where n is at least 3. The output arguments: outArray: A double precision 2D array of size nxn that is a copy of inArray except with the corners set to zero. • secondRow: A double precision 1D array of size n. This is the second row...

  • PLEASE USE MATLAB Create a single MatLab script that On a single line (Line 1), defines...

    PLEASE USE MATLAB Create a single MatLab script that On a single line (Line 1), defines matrix A such that A = 1 2 4. 5 7 8 Suppress the echo of A. On a single line (Line 2), use the size function to echo the size of A. On a single line (Line 3), use the length function to echo the length of the entire first row of A. On a single line (Line 4), use linear index notation...

  • using matlab In Class Exercises 8-Arrays For the following exercises, assume an array is already populated, your job is to write a program that traverses the array. DO NOT HARD CODE the last in...

    using matlab In Class Exercises 8-Arrays For the following exercises, assume an array is already populated, your job is to write a program that traverses the array. DO NOT HARD CODE the last index. In other words, you code for 1-4&6 should be able to handle the following 2 arrays: amp2 10 array1 [52, 63, 99, 71, 3.1] array2 - [99:-3: 45); For 5: wordArray1 wordArray2 ('number, 'arrays', 'indices', 'hello', finish' [number, 'different, 'finish? 1. Determine the sum of all...

  • Matlab coding assistance. Having some difficulty please help! thank you so much in advance! %% Task...

    Matlab coding assistance. Having some difficulty please help! thank you so much in advance! %% Task 9 % use logical tests to locate and update subsets of a matrix % Step 1: Create vec, a row vector of 5 random integers on the closed interval [-10,10]. % Step 2: Use a logical mask to count the number of positive values (code provided is already sufficient) mask = vec > 0 count = sum(mask) % Step 3: Use the find function...

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