Math Help - What command whould i use?

1. What command whould i use?

hi all, im not sure if this is the right place to ask, but i hope so ^^

im looking for an solution for my problem. im currently working in Matlab with an while loop witch calculates something for me, but he need's to do this 10000 times, so i made an while loop for it. so in the of the round of the loop it for example the number 10. im looking for an way to save this number.

the code i wrote is this (note: the ____ are just to make the reading fo the matrix easier, i left them out in the orignal code)
____________________________

%inserting values
R = 12000
C = 1.6e-9
n = 0

%the while loop

while n<5

n = n+1;
f(n)=n;

RC= 1/(j*2*pi*f(n)*C);
tRC=2/(j*2*pi*f(n)*C);

%insert of matrix 1

M1 = _[0___________(2/R)+(1/tRC)_(-1/R);
______(2/RC)+(2/R)__0____________(1/RC);
______(-1/RC)______(-1/R)________(2/RC)];

%insert of matrix 2
M2 = __[10/R;
_______10/RC;
_______0];

%calculate unknown values in the matrix
M = M1\M2

Vin = 10

%grab the value i need or my calculation
Vout= M(3,1)
H = Vout/Vin
end
_____________________________

so, now im looking for an way to store the value of H so i can plot into an graph later, any ideas how i can do this?

2. Hi

You could make a vector which you create before the while loop.
Lets call it A.

A=[]; %Create empty vector

Now in each loop, write

A=[A 'Your new number you wish to save'];

This way you should be able to save all the numbers, one new with every loop.

3. it works smoothly , thanks a lot

4. Assuming H is a scalar:

Code:

%inserting values
R = 12000
C = 1.6e-9
n = 0
HH=[];  %empty array to hold the output

%the while loop

while n<5

n = n+1;
f=n;

RC= 1/(j*2*pi*f*C);
tRC=2/(j*2*pi*f*C);

%insert of matrix 1

M1 = [0 (2/R)+(1/tRC)_(-1/R);
(2/RC)+(2/R) 0 (1/RC);
(-1/RC) (-1/R) (2/RC)];

%insert of matrix 2
M2 = [10/R;
10/RC;
0];

%calculate unknown values in the matrix
M = M1\M2

Vin = 10

%grab the value i need or my calculation
Vout= M(3,1)
H = Vout/Vin
HH=[HH,H];  % stuff result into extended output array
end


CB