I'm having a helluva time trying to build the index for this code.(adsbygoogle = window.adsbygoogle || []).push({});

First of all, this is homework, I'll admit, but I've done all I could

to research the problem on my own, so I understand the question I'm trying to ask by now, but I still haven't found an answer

Basically, I'm modeling Radioactive Decay in several different ways on

one plot. The issue I'm having is with the Euler method, because it's a numerical approach, and the last three years of my college life has been studying continuous.

Also, I have to use a while loop.

here is the code, followed by my question:

%----------------------------------------------------------------

%EULER

%----------------------------------------------------------------

i=1

t(1)=0

Ne(1)=100

while t>=ti & t<=tf %<---tf and ti are previously defined

t(i)=delt*(i-1)

Ne(i+1)=(1-lam*delt)*Ne(i)

i=i+1

end

plot(t,Ne,'ro')

------------------------------------------------------------------

Before plot even comes on, I can see that Ne will have one more

value than t does, and when I run it (when I run it, it says the matrices must must have an equal ammount of elements and such, and if I scroll

through the run, i can see that Ne has (as I assumed) one more value

than t.

So I try plot(t,Ne(i-1),'ro'), hoping it will return to the whole indix set one period ago for Ne, but no, it just takes the scalar of Ne at the i-1 index and gives me a nice flat line.

Question: How do I cut off the end of the matrices (Ne and t) to the same length like a paper cutter does with paper

OR

How do I enter a final value for one last indice after the loop has created a table (this would go after the 'end' of the loop and before the 'plot'.

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Matlab Indicing (help request)

**Physics Forums | Science Articles, Homework Help, Discussion**