Question

11. Create a cell array variable that would store for a student his or her name. university id number, and GPA. Print this information. 12. create a structure variable that would store for a student his or her name. university id number and GPA. Print this information. Please answer both 11 & 12 for matlab program
0 0
Add a comment Improve this question Transcribed image text
Answer #1

(11)

% Creating a cell array variable that store for a student name, id and GPA
studentCell = {'Tom', 12345, 84.2};

% Displaying student Cell array
fprintf("\n Created Cell Array: ");
disp(studentCell);

% Displaying student information by Accessing cell array
fprintf("\n\n Accessing Elements in Cell Array: \n\n Name: %s \t Id: %d \t GPA: %.2f \n\n", studentCell{1,1}, studentCell{1,2}, studentCell{1,3});

_____________________________________________________________________________________________

(12)

% Creating a structure variable that store for a student name, id and GPA
studentStruct = struct('Name','Jerry','Id',1011,'GPA',95.2);

% Displaying student structure
fprintf("\n\n Created Structure: ");
disp(studentStruct);

% Displaying student information by Accessing Structure variable
fprintf("\n\n Accessing Elements in Structure: \n\n Name: %s \t Id: %d \t GPA: %.2f \n\n", studentStruct.Name, studentStruct.Id, studentStruct.GPA);

_________________________________________________________________________________________________

Executing Both 11 and 12 by placing in a script:

% MATLAB Script that creates a Cell Array and Structure Variable

% ---------------------------------------------------------------------------------
% (11)
% ---------------------------------------------------------------------------------


% Clearing variables
clc;

% Clearing workspace
clear;

% Creating a cell array variable that store for a student name, id and GPA
studentCell = {'Tom', 12345, 84.2};

% Displaying student Cell array
fprintf("\n Created Cell Array: ");
disp(studentCell);

% Displaying student information by Accessing cell array
fprintf("\n\n Accessing Elements in Cell Array: \n\n Name: %s \t Id: %d \t GPA: %.2f \n\n", studentCell{1,1}, studentCell{1,2}, studentCell{1,3});

% ---------------------------------------------------------------------------------
% (12)
% ---------------------------------------------------------------------------------


% Creating a structure variable that store for a student name, id and GPA
studentStruct = struct('Name','Jerry','Id',1011,'GPA',95.2);

% Displaying student structure
fprintf("\n\n Created Structure: ");
disp(studentStruct);

% Displaying student information by Accessing Structure variable
fprintf("\n\n Accessing Elements in Structure: \n\n Name: %s \t Id: %d \t GPA: %.2f \n\n", studentStruct.Name, studentStruct.Id, studentStruct.GPA);

_______________________________________________________________________________________________

Sample Execution:

Add a comment
Know the answer?
Add Answer to:
Please answer both 11 & 12 for matlab program Create a cell array variable that would...
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
  • For the following array in the image below, create the MATLAB command that would generate it...

    For the following array in the image below, create the MATLAB command that would generate it and store it into a variable with a name such as 'pi'? 11 11 111] 2 22 222 13 33 333)

  • Write C++ program (studentsGpa.cpp) uses dynamic allocation to create an array of strings. It asks the...

    Write C++ program (studentsGpa.cpp) uses dynamic allocation to create an array of strings. It asks the user to enter a number and based on the entered number it allocates the array size. Then based on that number it asks the user that many times to enter student’s names. What you need to do:  Add another array of doubles to store the gpa of each student as you enter them  You need to display both the student’s name and...

  • 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,...

  • 2. Write a program named lab3 2.app that contains a class named Student to store student...

    2. Write a program named lab3 2.app that contains a class named Student to store student information Information that will be relevant to store is first name, last name, id number, GPA, and major (1) Define a member function named set0, which allows you to set all member variables. This function has an empty parameter list, and its return type is void. So, within the function you'll prompt for information. Note: For entering major, if you need a space, use...

  • ( Object array + input) Write a Java program to meet the following requirements: 1. Define...

    ( Object array + input) Write a Java program to meet the following requirements: 1. Define a class called Student which contains: 1.1 data fields: a. An integer data field contains student id b. Two String data fields named firstname and lastname c. A String data field contains student’s email address 1.2 methods: a. A no-arg constructor that will create a default student object. b. A constructor that creates a student with the specified student id, firstname, lastname and email_address...

  • SC 111 - BMCC Exam Student Name: Type # 4 - 20 Points write a program...

    SC 111 - BMCC Exam Student Name: Type # 4 - 20 Points write a program that uses a structure named Student to store the following information about a Student: Name ID GPA Address The program should create three Student instances, store values, and pass all of them to a function that displays the information about the Student in a clearly formatted manner. The program also uses another function to calculate and display the average GPA of all three Students.

  • 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...

  • Language is C programming Student ID should be 8 numbers long. create a program to read...

    Language is C programming Student ID should be 8 numbers long. create a program to read your student ID number and store it in an array. Input can not be hard wired, I have to be able to input my number Then change the first number to a letter. If the same number repeats in other parts of your student ID, you must change that number to a letter as well. print original array and modified array as your output....

  • Write a Java program that allows the following: 1.Create an array list of 20 integers. The...

    Write a Java program that allows the following: 1.Create an array list of 20 integers. The 20 integers are generated randomly with possible values from 0 to 10. 2.Print the content of the array list. 3.Find how many of these values are multiple of 3. Show a screenshot of the output with your name and Id in the first line (if there is no screenshot of the output, the student shall get a zero mark for this question). Program typical...

  • Please write a Java program that does the following: Create an array of 100 integers. Store...

    Please write a Java program that does the following: Create an array of 100 integers. Store 100 random integers (between 1 and 100) in the array. Print out the elements of the array. Sort the array in ascending order. Print out the sorted array. Prompt the user to enter a number between 1 and 100. Search the array for that number and then display "Found" or "Not Found" message. Display each number from 1 to 100 and the number of...

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