【发布时间】:2018-04-29 17:22:07
【问题描述】:
我遇到了一个问题,需要计算要在 Gmsh .geo 文件中使用的矩阵的系数。我使用 Matlab 创建了一个小脚本来求解 2x2 矩阵。代码如下;
clear all;clc;close all
R = 0.509515; % m
R1 = 0.559467; % m
R2 = 0.579594; % m
L = 0;
L1 = -0.08568;
L2 = 0.13974;
y = [R1-R;R2-R];
x = [L1^2 L1;L2^2 L2];
c = x\y;
x1 = linspace(-0.08568,0.13974,20);
从上面的小代码中,我需要使用矩阵c中的系数,我将其作为c1和c2手动转移到以下geo文件中
R = 0.509515; //% m
R11 = 0.10; //% m
R1 = 0.559467; //% m
R2 = 0.579594; //% m
L = 0;
L1 = -0.08568;
L2 = 0.13974;
c1 = 4.811;
c2 = -0.1708;
nPoints = 20; // Number of discretization points (top-right point of the inlet region)
For i In {1 : nPoints}
x = L1 + (L2-L1)*i/(nPoints + 1);
pList[i] = newp;
Point(pList[i]) = {x,
( c1*x^2+c2*x+R ),
0};
EndFor
Spline(1) = {20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
请注意,在地理文件中,我无法使用 linspace,因为我不知道 GMSH 中是否存在 linspace 语法。我的目标是让geo文件求解矩阵以拟合二次多项式。
【问题讨论】:
标签: matlab linear-algebra mesh