- #1
ephedyn
- 170
- 1
I've highlighted the areas which might have problems in red, especially boundary segment 1. I know
should be wrong, but I have no idea what to replace it with such that it works. There shouldn't be a problem with my parameter values I've highlighted it just in case. Does anyone know what's wrong with my code?
Thanks in advance!
Code:
x(ii)=interp1([dl(1,1),dl(2,1)],[0 2],s(ii));
should be wrong, but I have no idea what to replace it with such that it works. There shouldn't be a problem with my parameter values I've highlighted it just in case. Does anyone know what's wrong with my code?
Thanks in advance!
Code:
function [x,y]=expg2(bs,s)
%EXPG2 Creates a geometry file for an enclosed region of 3 line segments and 1 exp curve.
% Number of boundary segments
nbs=4;
if nargin==0 % Number of boundary segments
x=nbs;
return
end
dl=[
[COLOR="Red"] 0 0 0 0 % start parameter value
2 1 1 1 % end parameter value
0 0 0 0 % left hand region
1 1 1 1 % right hand region[/COLOR]
];
bs1=bs(:)';
if find(bs1<1 | bs1>nbs),
error('PDE:expg2:InvalidBs', 'Non existent boundary segment number.')
end
if nargin==1,
x=dl(:,bs1);
return
end
x=zeros(size(s));
y=zeros(size(s));
[m,n]=size(bs);
if m==1 && n==1,
bs=bs*ones(size(s)); % expand bs
elseif m~=size(s,1) || n~=size(s,2),
error('PDE:expg2:SizeBs', 'bs must be scalar or of same size as s.');
end
if ~isempty(s),
[COLOR="Red"]% boundary segment 1
ii=find(bs==1);
if length(ii)
x(ii)=interp1([dl(1,1),dl(2,1)],[0 2],s(ii));
y(ii)=exp(-s(ii));
end[/COLOR]
% boundary segment 2
ii=find(bs==2);
if length(ii)
x(ii)=interp1([dl(1,2),dl(2,2)],[2 2],s(ii));
y(ii)=interp1([dl(1,2),dl(2,2)],[exp(-2) 0],s(ii));
end
% boundary segment 3
ii=find(bs==3);
if length(ii)
x(ii)=interp1([dl(1,3),dl(2,3)],[2 0],s(ii));
y(ii)=interp1([dl(1,3),dl(2,3)],[0 0],s(ii));
end
% boundary segment 4
ii=find(bs==4);
if length(ii)
x(ii)=interp1([dl(1,4),dl(2,4)],[0 0],s(ii));
y(ii)=interp1([dl(1,4),dl(2,4)],[0 2],s(ii));;
end
end
Last edited: