How to calculate values at the nodal points?
조회 수: 1 (최근 30일)
이전 댓글 표시
hi!
Need to evaluate certain values at every nodal point. Have discretized then have used for loop to do calculation. Not getting any error but there is a variation in the result. My need is the value of P1,P2 ..... etc must be evaluated at each point. Do x_bar(j) represent the value of x_bar at the j th position (like x_bar(1)=0,x_bar(1)=0.01etc).
Xb = [0, .5, 1.25, 1.50];
delx_bar = [.01, .005, .0001];
x_bar = cumsum([Xb(1), repelem(delx_bar,diff(Xb)./delx_bar)]);
del_eta=0.02;
eta_inf=4;
n_xbar=length(x_bar);
eta=(0:del_eta:eta_inf).';
n_eta=length(eta);
for j=2:n_xbar-1
for i=2:n_eta
P1(j) = 1 - cos(x_bar(j));
P2(j) = 1 + cos(x_bar(j));
end
end
댓글 수: 2
Walter Roberson
2017년 9월 27일
What is the purpose of your "for i=2:n_eta" loop? You do not use "i" inside the loop.
채택된 답변
KSSV
2017년 9월 28일
Xb = [0, .5, 1.25, 1.50];
delx_bar = [.01, .005, .0001];
x_bar = cumsum([Xb(1), repelem(delx_bar,diff(Xb)./delx_bar)]);
del_eta=0.02;
eta_inf=4;
n_xbar=length(x_bar);
eta=(0:del_eta:eta_inf).';
n_eta=length(eta);
P1 = zeros([],[]) ;
P2 = zeros([],[]) ;
for j=2:n_xbar-1
for i=2:n_eta
P1(i,j) = 1 - cos(x_bar(j));
P2(i,j) = 1 + cos(x_bar(j));
end
end
댓글 수: 0
추가 답변 (1개)
AM
2020년 3월 26일
Hi, I need a help for my diploma work, can anyone help me to write my matlab code, it's so important.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!