Create vector of unknown size in Excel

I am trying to translate my existing Matlab code to Numbers (mostly Excel). In Matlab, I have the following code:

clear all; clc;
n = 30
x = 1:(n-1)
T = 295;

D = T./(n-x)

E = T/n

for i=1:(n-2)
    C(i) = D(i+1) - D(i)
end

hold on
plot(x(1:end-1), C, 'rx')
plot(x, D, 'bx')

      

I believe that all your decisions have been resolved, there are parts of them that I do not understand, otherwise I would try to figure out what it is. Result attached (also you may know that the formulas you gave work and are recognized in Numbers). I'm trying to figure out why (x) starts at 2 as I feel like it should start at 1?

It is also clear that realistic results for formulas exist only under certain conditions, i.e. in column E> 0. What would be the simplest way to slice data with a filter to slice only specific data?

enter image description here

+3


source to share


1 answer


(Using Excel ...)

Suppose you are putting your input values T and n in A1 and B1 respectively.

You can create x , D and the C . On columns C, D and E with:



C1: =IF(ROW()<$A$1,ROW(),"")

D1: =IF(LEN(C1)>0,$A$2/($A$1-C1),"")

E1: =IF(LEN(D2)>0,D2-D1,"")

Then you can pull out all 3 columns until you need to generate the full length of your vectors. If you want to map them out, just use these columns as input.

0


source







All Articles