Why isn't my line visible on this graph?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
function main
t = 0:0.5:2*pi;
p = 0:0.5:pi;
[T,P] = meshgrid(t,p);
sphr(1,0,0,0)
hold on
circ(2,0,0)
hold off
function s = sphr(r,a,b,c)
x = r.*cos(T).*sin(P)+a;
y = r.*sin(T).*sin(P)+b;
z = r.*cos(P)+c;
surf(x,y,z)
end
function c = circ(r,a,b)
x = r.*cos(T)+a;
y = r.*sin(T)+b;
line(x,y);
end
end
0 Kommentare
Antworten (1)
Edgar Guevara
am 14 Dez. 2017
Hi lmhall,
The circle should be defined as a function of a vector (small t), not the 2-Dgrid (capital T), so, pleace replace the following lines in your code:
x = r.*cos(T)+a;
y = r.*sin(T)+b;
with:
x = r.*cos(t)+a;
y = r.*sin(t)+b;
and you'll see the line.
Hope it helps,
Edgar
0 Kommentare
Siehe auch
Kategorien
Mehr zu Line Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!