Matlab: Changing shapes of PDEG

2 vues (au cours des 30 derniers jours)
Soheil  Esmaeilzadeh
Soheil Esmaeilzadeh le 9 Juin 2016
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.

Réponses (1)

Alan Weiss
Alan Weiss le 10 Juin 2016
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

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by