MATLAB a) You design a simple program that finds the volume of a cube. It takes
ID: 3727721 • Letter: M
Question
MATLAB
a) You design a simple program that finds the volume of a cube. It takes two inputs--a dimension and a string input that allows for two modes: SI and English unit systems. The string input takes either the strings "SI" or "English" as arguments. If you want to see which string the user input, which command should you use?
b) You decide to modify your parts inventory system to work with MATLAB. You have the following parts, which you store in a data structure called parts:
parts={'10k resistor', '1k resistor', 'Ceramic capacitor', 'transistor'}
What command would you use to refer to the third part (which in this case happens to be a ceramic capacitor)?
c) You decide to reorganize your parts file to have one column of names and another of part numbers:
parts={'10K resistor',34; '1K resistor',65; 'Ceramic capacitor',98; 'Transistor',132}
What is the command that you would use to find the part number for the ceramic capacitor?
d) You decide to reorganize your parts file yet again to have a structure featuring parts and part numbers:
parts(1).name='10K resistor';
parts(2).name='1K resistor';
parts(3).name='Ceramic capacitor';
parts(4).name='Transistor';
parts(1).number=34;
parts(2).number=65;
parts(3).number=98;
parts(4).number=132;
What is the command that you would use to output the part number for the ceramic capacitor?
- These should be fairly simple questions, but I cannot seem to find examples in my MATLAB book. Hope you can help.
Explanation / Answer
a) You design a simple program that finds the volume of a cube. It takes two inputs--a dimension and a string input that allows for two modes: SI and English unit systems. The string input takes either the strings "SI" or "English" as arguments. If you want to see which string the user input, which command should you use?
Ans)string=input("Enter mode : ",'s')
you will get:-
Enter mode : si
string = si
b) You decide to modify your parts inventory system to work with MATLAB. You have the following parts, which you store in a data structure called parts:
parts={'10k resistor', '1k resistor', 'Ceramic capacitor', 'transistor'}
What command would you use to refer to the third part (which in this case happens to be a ceramic capacitor)?
Ans)thirdArgument=parts(3)
You will get answer:-
thirdArgument =
{
[1,1] = Ceramic capacitor
}
-------------------------------------------------------------------------------------------------------------------
c) You decide to reorganize your parts file to have one column of names and another of part numbers:
parts={'10K resistor',34; '1K resistor',65; 'Ceramic capacitor',98; 'Transistor',132}
What is the command that you would use to find the part number for the ceramic capacitor?
Ans)thirdArgumentNumber=parts(3,2)
You will get answer:-
thirdArgumentNumber =
{
[1,1] = 98
}
-------------------------------------------------------------------------------------------------------------------------
d) You decide to reorganize your parts file yet again to have a structure featuring parts and part numbers:
parts(1).name='10K resistor';
parts(2).name='1K resistor';
parts(3).name='Ceramic capacitor';
parts(4).name='Transistor';
parts(1).number=34;
parts(2).number=65;
parts(3).number=98;
parts(4).number=132;
What is the command that you would use to output the part number for the ceramic capacitor?
Ans) partNumber=parts(3).number Or partNumber=parts(1,3)
you will get:-
partNumber = 98
or
partNumber =
scalar structure containing the fields:
name = Ceramic capacitor
number = 98
----------------------------------------------------------------------------------------------------------------------------
Note:-
As per my understatding about the question , you want simple commands to return proper values.
If you expect differently,let me know
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.