*********************program**************************
octave:1> x=2
x = 2
octave:2> for i=-1:-1:-3
> > x=[x,2*x]
> > end
***********************output****************************
x =
2 4
x =
2 4 4 8
x =
2 4 4 8 4 8 8 16
******************************explaination*************************
initial x value=2
for loop starts from -1 till it reaches to -3 by incrementing -1 step at a time
so, for expression x=[x , 2*x]
i value |
X value |
Expression x=[ x, 2*x] |
Output |
-1 |
2 |
=[2,2*2] |
[2,4] |
-2 |
4 |
=[4,2*4] |
[4,8] |
-3 |
8 |
=[8,2*8] |
[8,16] |
Finally answer will be:
x =
2 4 4 8 4 8 8 16
The value of X is:
X=
2 4 4 8 4 8 8 16
Correct Answer is:- B
----------------------
Explanation :-
Execute this Code on matlab compiler:-
X=2;
for i=-1:-1:-3
{
X=[X, 2*X];
fprintf('value of x: %d\n', X);
}
end
X
-----------------------------------------------------------------
Initially X=2, now it for loop execute three times(i=-1,-2,-3)
Steps (1). for i=-1, X= 2 and X=[X, 2*X] so X= 2 4
Step (2) for i=-2 , X=4 and X=[X, 2*X] so X= 4, 8
Step (3) for i=-3 and X=[X,2*X] will be 4 8 8 16 (here X=[4, 4*2] will be 4 8 and X=[8, 8*2] will be 8 16)
---------------------------------------------------------------------------------------------------------------------
If you have any query, please feel free to ask.
Thanks a lot.
explain please What is the value of X at the end of this MATLAB code? X=2;...
for this matlab code what is the value of ires at the end of the code? ires = 0; for index = 10:-2:4 if index == 6 break; end ires = ires + index; end
I need a matlab code for given question. Please send matlab code sctript. a:2 b:3: c:4 d:2.1 e:3.1 Question 1) (60 p) Consider following equation: axt-bx'+ex=dx-e Find the value of x via; a) Fixed Point iteration method with an accuracy of 0.0004 and a starting value of 1. b) Newton's Method with an accuracy of 0.0004 and a starting value of 1. Write the codes and the results to your paper.
MATLAB code question. Please keep is basic P4.3.6 What is the smallest value of n such that the value of factorial(n) is inf?
Please send the Matlab code 2. Compute the Fourier series coefficients for x(t) using MATLAB and plot the double-sided spectra up to the 10th harmonic. (20 points) 수 x(t) -10 10 20 30
Using MATLAB please. A = rand(m,n) x = rand(n,1) b = A * x 1. What does the following code compute? Explain what operation the third line is per- forming b = zeros(m, 1); for i = 1:m b(i) = A(i,:) * x; end Make a copy of the relevant MATLAB function you wrote earlier, and use this code in place of the two loops you wrote. Time both codes on a sufficiently large problem. Which performs faster?
Please provide MATLAB code and comments! Please provide MATLAB code and comments! Please provide MATLAB code and comments! Question #5. Write a script that creates a variable called BALANCE that is assigned the value 100.00. Then prompt the user to enter an amount to withdraw. Store that amount in a variable called WITHDRAW. Use an if/else construct to display a message to the user stating whether the withdrawal was successful. If the withdrawal would result in a negative balance, state...
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
Q: please solve using matlab code withe comment 1. Write the Matlab code to generate: x = cos(w1*t) + cos(w2*t); where, w1=7; w2=23; t = [0:0.005:2] 2. Plot the signal using sub plot a. in time domain b. in frequency domain 3) Sample the signal under different sampling conditions: a. Ts<1/2fm b. Ts=1/2fm c. Ts>1/2fm 4). Multiple plot: the signal sampled under sampling condition and the signal x a. in time domain b. in frequency domain c. Label and Title...
matlab code please MATLab 1. Using MatLab, write a program to calculate the range of x values for a Gaussian distribution assuming an arbitrary confidence (e.g. 85%) Suppose that there are 3000 air molecules in an otherwise empty room. What is the probability that exactly 1000 of them are in the front third of the room at any instant? What is the probability that 1001 of them are in the front of the room? What is the probability that there...
2. What is the value of x alter the following code is executed # include<iostream> using namespace std; int main int t-0, c- 0,x-3; while (c < 4) t=t+x; cout << x return 0; a) 3 b) 21 c) 24 d) 48 3. What is the output of the following code? # include<iostream> using namespace std; int main0 int a- 3; for (int i 5; i >0; i) a a+i cout << a << “ “ return 0; d) 8...