Question
MATLAB Problem 1a: In this problem, you are going to create a function that takes 4 inputs and returns a structure. The function has the
MATLAB
Problem 1a:
In this problem, you are going to create a function that takes 4 inputs and returns a structure. The function has the format: Function structure = Construct ( brand, color, VIN, operational ) There are some requirements for this function:
1) If the number of inputs is not 4, display Error: Incorrect number of field values provided.
2) The input brand must be string, if not, display Error: brand must be string.
3) The input color must be string, if not, display Error: color must be string.
4) The input VIN is a mix of string and numbers. Its 6 digits in total. The first digit will be a character V, the others will be numbers. You can use isstrprop() function. Use isstrprop(array, alpha) or isstrprop(array,digit) to check the string. For example:
If the format is not correct, display Error: VIN format is not correct.
5) The input operational must be Boolean value, True or False. If not, display Error: operational must be Boolean.
6) When the structure is successfully created, display information recorded!
Problem 1b:
Use the function you have write to create an array of structure, which includes the following information:
Brand | color | VIN | operational |
Honda | White | V12345 | true |
BMW | Black | V23451 | false |
Buick | Red | V34512 | false |
Mazda | Silver | V45123 | true |
Audi | Black | V51234 | true |
For example, create a car structure with the construct function: car1 = construct(Honda, White, V12345, true). All the structure will be put into an array.
Problem 1c
Use for loop to filter all the cars whose operational is True and display their VIN.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started