Matlab: Changing shapes of PDEG
Mostrar comentarios más antiguos
I have the below function:
function [x,y] = cardioid2(bs,s)
if nargin == 0
x = 4; % 4 segments
return
end
if nargin == 1
% Outer cardioid
dl = [ 0 pi/2 pi 3*pi/2
pi/2 pi 3*pi/2 2*pi
1 1 2 2 % To the left is empty
0 0 0 0]; % To the right is region 2
dl = [dl];
x = dl(:,bs);
return
end
x = zeros(size(s));
y = zeros(size(s));
if numel(bs) == 1 % Does bs need scalar expansion?
bs = bs*ones(size(s)); % Expand bs
end
cbs = find(bs < 3); % Upper half of cardiod
x(cbs) = (4+0.1*cos(s(cbs))).*cos(s(cbs));
y(cbs) = (4+0.1*cos(s(cbs))).*sin(s(cbs));
cbs = find(bs >= 3 & bs <= 4); % Lower half of cardioid
x(cbs) = 4*cos(s(cbs));
y(cbs) = 0;
save('my_parameters.mat')
end
By running code:
pdegplot('cardioid2','EdgeLabels','on')
A semicircle with radius of 4 will be generated.
I do not know how would it be possible to to modify the code in a way I can have the radius vary proportional to polar angle (let's say r=1+0.2cos(teta)) where teta is from 0 to pi.
Please if you cannot help at least do not vote down, it will pose me to being blocked.
Respuestas (1)
Alan Weiss
el 10 de Jun. de 2016
0 votos
I am not sure that I understand what you are asking, but did you see the cardioid3 example from the documentation? It does not make a semicircle, it makes a cardioid, where the radius depends on angle.
Alan Weiss
MATLAB mathematical toolbox documentation
Categorías
Más información sobre Function Creation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!