Basic MATLAB help Loop types: For For statements loop a specific number of times
ID: 1526380 • Letter: B
Question
Basic MATLAB help
Loop types: For For statements loop a specific number of times, and keep track of each iteration with an incrementing index variable. While While statements loop as long as a condition remains true. if evaluates an expression, and executes a group of statements when the expression is true Switch evaluates an expression and chooses to execute one of several groups of statements Write code to calculate the following iterative expression where x goes from 0 to 10 in steps of h = 0.1 and the initial value of y is 1. Y_j + 1 = y_j + hx_j Check the sizes of your x and y vectors. If necessary change your code so that they are the same size.Explanation / Answer
X=linspace(0,10,101);
Y=zeros(1,101);
Y(1) = 1;
for n = 2:101
Y(n)=Y(n-1)+0.1*A(n-1);
end
The sizes of X and Y vectors are 1x101.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.