3 views (last 30 days)

This question was flagged by Jan

Given the following equation,

Given, d0=0.1 & d1=0.01 and model depends on value of b.

Now for b = 0.1, 0.2, 2.3, 2.6, 3, I am asked to find the largest proper value of xn for each of these values of b.

xn is said to be proper when xn+1 is nonnegative.

I am also asked to find a formula for largest proper value of xn in terms of b.

Can anyone help me with the syntax I need to do this? There are many more situations I need to consider but if I can get this one syntax, I will be able to understand the rest.

Also for context I have no clue how to start this. My professor suddenly gave me this and we haven't been taught MATLAB yet. This is only part of the question so if someone could provide how to do this one, I will be able to figure out the rest 4 questions. Thank you.

Bob Nbob
on 1 Jul 2019

For the most part, the syntax on this is pretty straight forward. The equation itself will look very similar to how it is written there.

I'm not entirely sure if you are looking for the largest value of xn that is proper, or if you are looking for the largest value of n, but the following should generally cover both situations. It is going to be a pretty basic setup, so it should be easy to follow. There are probably more advanced ways of determining this, but if you don't know anything about Matlab, I would suggest you start with this.

d = [0.1 0.01]; % Defining constants

b = [0.1 0.2 2.3 2.6 3]; % Defining all possible values of b

sets = nan(length(b),2); % Initialize blank value to store results

for i = 1:length(b) % Loop through all values of b

B = b(i); % Set value for this loop

xn = 1; % Set an initial value of xn, because you kind of need it. Replace as needed

n = 0; % Initialize value of n

while xn ~< 0 % Run until xn becomes negative

xnp = xn; % Record previous value of xn

xn = xn + B*xn - d(1)*xn - d(2)*xn^2;

% Calculate xn+1

n = n + 1; % Advance value of n

end

sets(i,:) = [xnp, n-1]; % Record results

end

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 5 Comments

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/469762-new-to-matlab-so-need-help-with-following#comment_720288

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/469762-new-to-matlab-so-need-help-with-following#comment_720288

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/469762-new-to-matlab-so-need-help-with-following#comment_720290

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/469762-new-to-matlab-so-need-help-with-following#comment_720290

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/469762-new-to-matlab-so-need-help-with-following#comment_720298

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/469762-new-to-matlab-so-need-help-with-following#comment_720298

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/469762-new-to-matlab-so-need-help-with-following#comment_720301

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/469762-new-to-matlab-so-need-help-with-following#comment_720301

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/469762-new-to-matlab-so-need-help-with-following#comment_720457

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/469762-new-to-matlab-so-need-help-with-following#comment_720457

Sign in to comment.