How to generate 1-D meshing in MATLAB
조회 수: 20 (최근 30일)
이전 댓글 표시
Hi, Everyone warm greeting, I want to ask a question please answer me if anyone is working in this area.As attached in Figure 1 and 2. I want to generate one dimensional mesh and store initial values,in Figure 1 i have written for i=1:1:length a(i)=5;% i have many variable here i have written only one. end The problem I am facing in Figure 2 due to branch at one point and then combines at other point. I have written like for i=1:1:length a(i)=6; end for i=1:1:L a(i)=5; end The problem is after writing the second matrix it is replacing these values with earlier one,so i am unable to solve my problem please help me.... sry for bad english...
for i=1:1:length a(i)=5;% i have many variable here i have written only one. end
for i=1:1:length a(i)=6; end for i=1:1:L a(i)=5; end
댓글 수: 0
답변 (1개)
KSSV
2016년 7월 21일
I suggest you to use parametric equation of line..
%%figure 1
% mesh a line
N = 50 ;
t = linspace(0,1,N) ;
p0 = [0 0] ; % first point of line
p1 = [5 0] ; % second point of line
% Paremtric equaiton of line
x = p0(1)+(p1(1)-p0(1))*t ;
y = p0(2)+(p1(2)-p0(2))*t ;
figure ;plot(x,y,'.-r')
%%Figure 2
% coordinates of the corner points
p0 = [0 0] ;
p1 = [3 0] ;
p2 = [6 0] ;
p3 = [9 0] ;
p4 = [3 1] ;
p5 = [6 1] ;
% line 1
x1 = p0(1)+(p1(1)-p0(1))*t ;
y1 = p0(2)+(p1(2)-p0(2))*t ;
% line 2
x2 = p1(1)+(p2(1)-p1(1))*t ;
y2 = p1(2)+(p2(2)-p1(2))*t ;
% line 3
x3 = p2(1)+(p3(1)-p2(1))*t ;
y3 = p2(2)+(p3(2)-p2(2))*t ;
% line 4
x4 = p1(1)+(p4(1)-p1(1))*t ;
y4 = p1(2)+(p4(2)-p1(2))*t ;
% line 5
x5 = p2(1)+(p5(1)-p2(1))*t ;
y5 = p2(2)+(p5(2)-p2(2))*t ;
% line 6
x6 = p4(1)+(p5(1)-p4(1))*t ;
y6 = p4(2)+(p5(2)-p4(2))*t ;
%
figure
plot(x1,y1,'.-r') ; hold on
plot(x2,y2,'.-r')
plot(x3,y3,'.-r')
plot(x4,y4,'.-r')
plot(x5,y5,'.-r')
plot(x6,y6,'.-r')
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!