making new code by calling 3 different RANDOM variables

[EDIT: 20110627 13:09 CDT - reformat - WDR]
This function will generate a normal distribution conditional by bounds:
i have used above code 3 times and made 3 random variables c, fi, G. now i want to calculate qult.
this is my code :for getting distribution of qult i need to produce 3 different random variables (c, fi, G) by above code and call them in a new code to get answer. how should i use c, fi, G that i produced and call them in a loop to compute qult.
this is my code for qult:
B=1000;L=2000;Sc=1.1;Sq=1.1;Sgama=.8;
nsamples=10000;
for i=1:nsamples
C=C(1,i);
G=G(1,i);
fi=fi(1,i);
Nq=tan((pi/4)+(pi*fi/360))*tan((pi/4)+(pi*fi/360))*2.718^(pi*tan(fi*pi/180));
Nc=(Nq-1)*cot(fi*pi/180);
Ngama=2*(Nq+1)*tan(fi*pi/180);
qult(i)=(C*Nc*Sc)+(384*Nq*Sq)+(980*Ngama*Sgama);
end

8 件のコメント

Jan
Jan 2011 年 6 月 27 日
Please use the "{} Code" button to format your code such that it is more readable.
Andrew Newell
Andrew Newell 2011 年 6 月 27 日
What is qult?
milad babaei
milad babaei 2011 年 6 月 28 日
qult :this equation calculate ultimate bearing capacity of shallow foundation (geotechnical eng.)
Krishna Kumar
Krishna Kumar 2011 年 6 月 28 日
how can you use C=C(l,i).Wont that return an error.
Better use different values for the purpose. The UBC or Qult formula uses one value of C Nc,etc, so you should be using C(l,i).
Further, what is the problem you are facing with this?
milad babaei
milad babaei 2011 年 6 月 28 日
Nq,Nc,Ngama are bearing factors.
Krishna Kumar
Krishna Kumar 2011 年 6 月 28 日
you still havent elaborated on your problem. Also why run two threads?
milad babaei
milad babaei 2011 年 6 月 28 日
after running and generating values for C,fi and G.then run qult code, this error first shows up :
??? Attempted to access C(1,2); index out of bounds because numel(C)=1.
Error in ==> tbc at 4
C=C(1,i);
would u plz explain me mre to what should i do for correcting indexes ??
Krishna Kumar
Krishna Kumar 2011 年 6 月 28 日
Refer to my earlier comment here. if a matrix X is 5x5, and you do sth like this
X=X(3,1);
Now X is a scalar. The next time if you run
X(4,1), error is generated, since X is 1x1.
You need to use separate variables for the matrix of random numbers and the particular random num taken in loop.

サインインしてコメントする。

 採用された回答

Walter Roberson
Walter Roberson 2011 年 6 月 28 日

0 投票

On the first iteration through the loop, your statements
C=C(1,i);
G=G(1,i);
fi=fi(1,i);
are equivalent to
C=C(1,1);
G=G(1,1);
fi=fi(1,1);
That is, you take a single value out of the array C and you replace the entire array C with that single value; likewise for G and fi. So after the first iteration, C and G and fi each only have one element left.
What you should do is rename your C, G, and fi variables so that you are not storing over your C, G, and fi arrays.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by