Question: I was able to create a working myBubbleSort function which returns an array of numbers in order from least to greatest, but I can't figure
I was able to create a working myBubbleSort function which returns an array of numbers in order from least to greatest, but I can't figure out vector sort, I posted what I have below. Thanks!
function [ outputArray ] = myBubbleSort( inputArray , n ) x = inputArray; n = length(x); sort = 0; k = 0; while ~sort sort = 1; k = k + 1; for j = 1 : n-k if x(j) > x(j + 1) temp = x(j); x(j) = x(j + 1); x(j + 1) = temp; sort = 0; end end end outputArray = x; end

3.3 VectorSort D Modify VectorSort.m, so that the function returns the sorted magnitude of the vectors from small to large. D You can use the function you wrote, myBubbleSort.m in the previous exercise Vectors are structs, x and y are the coordinates of a vector, the length of a vector is the root of the summation of x square and y square
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
