Here's the solution:-
1.B
2.A
3.C
4.B
section break
2.
(a) 4<5 & 6>7
ans = 0
(b)(5=5)|1
parse error:
invalid constant left hand side of assignment
(c)(1 & 1 | 0)
ans = 1
3.>> for i=1:4
a=5
a=a+5
end disp(a)
OUTPUT:-
parse error:
syntax error
>>> end disp(a)
4.(a)>> x=3;
>> while(x<8)
disp('Am I done yet?')
x=x+2.5;
end
OUTPUT:-
Am I done yet?
Am I done yet?
(b)
>> c=0;
>> i=10;
>> while i~=1
c=c+i;
i=i-3;
end
Ans.
The loop will run 3 times
5.
(a)
V~=X
ans =
1 1 1 1
(b)
V==Y
ans = 0
(c)
X+Y/2
ans =
41.500 37.500 38.500 41.500
(d)
X(V~=X)
ans =
7 3 4 7
(e)
Y>7
ans = 1
(f)
Y(Y>7)
ans = 69
6. OUTPUT
>> a
a = 20
>> b
b = 80
>> c
c = 2
>>
7
(a) No Output since I is less than 5 always, I=1
(b)OUTPUT:-
Move right
matlap Question 1 1. Consider the following Matlab program 5 - (2 < 3) & (C2...
Matlab for engineers 5th edition please help me with this problem with explanation. Consider the following mathematical expression to create a single input-output function. y= −x3+ x2 + 2 a)Create a single input-output function that can accept scalar and matrix values. b)Plot the output versus the input, and properly label the axes and add a title. Note: the plot command should be coded inside the function file. c)Calculate y values for x= [−10, 10] with an appropriate increment.
You should test out your script using the following matrices. 2 3 1 2 3 1 C D- 3 2 B- A- -3 8 4 8 2 4 4 1 You may not use any special MATLAB tools. Instead, work symbolically and derive general expressions for the eigenvalues and the eigenvectors. For instance, you may not use the SOLVE function. If you are not sure whether or not a particular function is available to you, just ask Include your hand...
MATLAB scripts are how multiple lines of code can be executed vs. entering in a line of code one at a time through the command window. Write a script that does the following. Only display to the console window what is specified. Creates a 4 x 10 matrix with the 1strow being 1 to 10, the 2ndrow being 11 to 20, the 3rdrow being 21 to 30, and the last row being 31 to 40. The matrix is shown on...
Question 5: Consider the following C++ program. switch(x) case 1: if (x > 1) case 2: if (x > 3) case 3: cout<<"Epic Beats!" << endl; case 4: cout << "Chill Vibes" << endl; break; case 5: cout << "Sweet Jazz" << endl; break; default: cout << "Invalid input. Try again."; A. What is the output if x = 1? B. What is the output if x = 3? C. What is the output if x = 2? D. What...
Please show the code necessary, and explanations on MATLAB. Plotting 11) Plot the function y = sin(x) from x = 0 to 21. 12) Plot the functions y = x2 z = x2 + 2x + 1 from x = 0 to 2 on the same graph. Scripts: Input and Output 13) Write a script (M-file) to read in a message at the command line using the MATLAB input function and then display the message to the Command Window using...
Question 1: Creating a user-defined function Write a user-defined MATLAB function named PBTask4pl_f.m for the following math function with x the input argument and y the output y(x)=0.8x4-13x2-5x The function should work for x being a scalar or a vector. Write a script file named PBTask4pl.m to a) Use the function to calculate y(3) and y(5) and display the results in command window b) Use the function to make a plot of the function y(x) for -5:5: x 5:5. Label...
MATLAB Problem HW7P2 (20 points) (5 pts) Write a user-defined MATLAB function called HW7P2_fn for the following math function 3 o-0.47x The input to the function is x and the output is y. Write the function such that x can be an array (use element-by-element operations) (15 pts) Use the function in (a) the command window to calculate y(-2) and y(5) (b) a script file HW7P2.m to determine y(x) for 0.001 Sx S 10 with 1000 points. Hint: Use the...
Can you explain how this works? (cl) The following Matlab code is executed. What is Matlab's output? x - [0 1 2*ones(1, 4)]; b -2:3]. 2; y -x.*b; disp(y); Solution: 010 28 18
in MATLAB 4-5], what will be displayed ifthe following Given u 1-3 2 executed by MATLAB? nu (a)1 1 (b) 1 -3 4 -5 (c) -1 2 (d) 1 (e) o 1
help me please , By using MATLAB How can I plot the solution of linear diffrential system ? I want the code in general case We were unable to transcribe this imageclose all clear MATLAB Code: clc A= [1 0 1; 0 0 0;00-1]; % Coefficient Matrix Xo = [5 76]'; % Initial condition V, D = eig(A); % Get the Eigen values and Eigen vectors % General Solution: X=Sum of {c_i*exp(L_i*t) *V_i % where c_i are constants, L_i are...