- #1

- 14

- 0

## Homework Statement

I am having a bit of a problem trying to understand while loop.

I was given a question lke this

Write a while loop to evaluate the

**spl**of effective pressure

**p**starting from

**pref**and increasing by a factor of 2 at a time.The program should stop when the spl exceeds 100 db.The output should clearly show

**p**and

**spl**at each step

**pref=20x10-6 spl=20log10(p/pref)**

But it keeps making matlab crash by giving me an infinite loop.

## Homework Equations

## The Attempt at a Solution

My code was like this

pref=2/1000000;

p=pref;

spl=20*log(10);

while spl<100;

spl=20*log(10)*(p/pref)

p=p^2

end