Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2nd photo is vorder.m. vorder.mat is a 1x20 vector array with the following numbers from 1-20: 17,25,19, 20,15,30,18,23,27,13,26,14,22,16,12,11,28,29,21,24. 1. Debug program 'vorder.m' ( vorder.m @

image text in transcribedimage text in transcribed

2nd photo is vorder.m. vorder.mat is a 1x20 vector array with the following numbers from 1-20: 17,25,19, 20,15,30,18,23,27,13,26,14,22,16,12,11,28,29,21,24.

1. Debug program 'vorder.m' ( vorder.m @ ) that reorders the input vector by placing the smallest element in the first element and the largest element as the last element of the output array and preserves all the other elements of the input vector. Correct all errors in vorder.m to have a fully functional code. 2. Document code by providing comments and explanation for each line of the code 3. Create additional comment line for each error you find. Please start the additional line describing error with: % E: ... Create test script to test the function using vector x from MAT file 'vorder.ma ( vorder.mat) that should be downloaded from Canvas and loaded first in the test script. Integrate function vorder at the bottom of the test script and submit only one .M file to Canvas. Print the original vector and ordered vector according to the requirements using formatted print. . function y=vorder(x) % vorder orders input vector and generates output vector y % y=vorder(x) % % Output vector has the smallest element in the first position % and the largest element as the last element of the array. % All elements of the input vector are preserved in the output vector. % N=length(x); y1=x; for i=2: N-1 if y(i-1)>y(i) tmp=y(i); y(i-1)=y(i); y(i)=tp; end for i=N-1:2 if y(i)

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

Recommended Textbook for

Advanced Database Systems For Integration Of Media And User Environments 98

Authors: Yahiko Kambayashi, Akifumi Makinouchi, Shunsuke Uemura, Katsumi Tanaka, Yoshifumi Masunaga

1st Edition

9810234368, 978-9810234362

More Books

Students also viewed these Databases questions