Question
use matlab do clearly
2) Write a MATLAB function that takes a structure array holding information about students (name, age, GPA) and returns this
0 0
Add a comment Improve this question Transcribed image text
Answer #1

function structureArray=bubbleSort_structure(structureArray)
swapped=true;
while swapped
swapped=false;
for i=1:length(structureArray)-1
if structureArray(i).age>structureArray(i+1).age
temp=structureArray(i);
structureArray(i)=structureArray(i+1);
structureArray(i+1)=temp;
swapped=true;
end
end
end
end

GPA! 1. SUUU >> sorteds (2) ans = struct with fields: name: Name age: 19 GPA: 7 >> sorteds (3) ans = struct with fields: na

Command Window >> students (1) .name=Namel; students (1).age=21; students (1) .GPA=6; students (2).name=Name2; students (

Add a comment
Know the answer?
Add Answer to:
use matlab do clearly 2) Write a MATLAB function that takes a structure array holding information...
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 Write a function maxContent(arr) that takes a cell array arr as input and returns the...

    MATLAB Write a function maxContent(arr) that takes a cell array arr as input and returns the longest string and largest number in arr. If there are two character arrays of same length, the function should return one of them. Assume that integers in the cell array are nonnegative.

  • Sorting Sort the following array using the quick sort algorithm: (4 Marks) a. 12 26 8...

    Sorting Sort the following array using the quick sort algorithm: (4 Marks) a. 12 26 8 9 7 0 4 Pivot selection is defined to be the first element of each sub-list. Show the array before and after each quicksort round (when the array is partitioned after placing the pivot at its correct position). Also, clearly highlight the pivot in each partition b. Consider an unsorted array of integers of size n. Write a Java program to arrange the array...

  • In C only Please! This lab is to write a program that will sort an array...

    In C only Please! This lab is to write a program that will sort an array of structs. Use the functions.h header file with your program. Create a source file named functions.c with the following: A sorting function named sortArray. It takes an array of MyStruct's and the length of that array. It returns nothing. You can use any of the sorting algorithms, you would like though it is recommended that you use bubble sort, insertion sort, or selection sort...

  • Programming language: Java Home Work No.2 due 09.11.2019 either ascending or descending SORTING: An array is...

    Programming language: Java Home Work No.2 due 09.11.2019 either ascending or descending SORTING: An array is said to be ordered if its values order. In an ascending ordered array, the value of each element is less than or equal to the value of the next element. That is, [each element] <= [next element]. A sort is an algorithm for ordering an array. Of the many different techniques for sorting an array we discuss the bubble sort It requires the swapping...

  • MATLAB function Write an efficient function, f(v) that takes a one-dimensional array of length N^2 for...

    MATLAB function Write an efficient function, f(v) that takes a one-dimensional array of length N^2 for a square matrix (in a row-vectorized form) as an input and returns the trace of the matrix.

  • In Java 2. Array Exercise ( 10 points) Write a Java program that will prompt the...

    In Java 2. Array Exercise ( 10 points) Write a Java program that will prompt the user to input a size of an array. Create an array of type int. Ask a user to fill the array. Create a functions sortArray() and mostFrequency(). The sortArray() function will sort number into incrementing order. The sorting function must be implemented from scratch and it must not use any function from the library. Feel free to use any sorting algorithm. The program will...

  • Do the following: - Write and test a function that takes an array of doubles and...

    Do the following: - Write and test a function that takes an array of doubles and returns the average of the values in the array - Write and test a function that takes an array of doubles and returns number of values in the array that are above the average of the values in the array - Write and test a function that takes an array of Strings and returns number of values in the array that start with an...

  • What would the function look like in MATLAB? Write a function called mysort that takes a...

    What would the function look like in MATLAB? Write a function called mysort that takes a 3-element vector as its sole arguments. It uses if statements, possibly nested, to return a 3-element vector with its elements in non-decreasing order, i.e., the first element in the returned vector equals the smallest element of the input vector and the last element equals the largest element in the input vector. NOTE: Your function should not use any built-in functions, e.g., sort, min, max,...

  • Matlab a) Write a MATLAB code that takes the grade letters from the user and provide him/her with the GPA for that seme...

    Matlab a) Write a MATLAB code that takes the grade letters from the user and provide him/her with the GPA for that semester Enter your grades (letters): AABBC (input) Your GPA is 3.2 output) b) Write a Matlab user defined function to that takes a letter grade and return a numeric grade as shown in the table below. Any other value should give an error message (Invalid Grade). You function name should be Letter2Grade Use the following information to calculate...

  • *** write in matlab *** use for loops largestfactor_for Write a function that takes a positive integer greater than one...

    *** write in matlab *** use for loops largestfactor_for Write a function that takes a positive integer greater than one and returns its largest factor (other than itseir). You must use a for loop to solve this problem. Do not use functions factor), primes(), and divisors() . Do not use while loops Do not use vectorized code. alargestfactor 105) 35 largestfactor_for Write a function that takes a positive integer greater than one and returns its largest factor (other than itseir)....

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
ADVERTISEMENT