- #1

- 161

- 14

Moved from a technical forum, so homework template missing

Hello All,

I have a question regarding a MATLAB homework problem. I am learning about logical functions and selection structures.

Here is the question:

The height of a rocket (in meters) can be represented by the following equation:

height=(2.13*t^2)-(0.0013*t^4)+((0.000034*t^(4.751))

create a vector of time(t) values from 0 to 100 at 2 sec intervals

A)Use the find function to determine when the rocket hits the ground to within two seconds.

B) use the max function to determine the maximum height of the rocket and the corresponding time.

I believe I can do part A, part B is what I am struggling with. Here are my attempts:

A)

<Moderator's note: code tags added. Please use them.>

My attempt at B:

It is at this part that I get an error saying: Array indices must be positive integers or logical values...

Any help would be appreciated. I assume it has something to do with indexing?

Thanks

I have a question regarding a MATLAB homework problem. I am learning about logical functions and selection structures.

Here is the question:

The height of a rocket (in meters) can be represented by the following equation:

height=(2.13*t^2)-(0.0013*t^4)+((0.000034*t^(4.751))

create a vector of time(t) values from 0 to 100 at 2 sec intervals

A)Use the find function to determine when the rocket hits the ground to within two seconds.

B) use the max function to determine the maximum height of the rocket and the corresponding time.

I believe I can do part A, part B is what I am struggling with. Here are my attempts:

A)

Matlab:

```
t=0:2:100
height=(2.13*(t.^2))-(0.0013*(t.^2))+(0.000034*(t.^4.751))
posHeight=find(height>0)
M=max(posHeight)
ans_a=t(a)
```

My attempt at B:

Matlab:

```
MaxHeight=max(height)
CorrTime=t(MaxHeight)
```

Any help would be appreciated. I assume it has something to do with indexing?

Thanks

Last edited by a moderator: