Plot in for loop
이전 댓글 표시
function plot_EM_cath(raw_EM_cath)
figure numcath = size(raw_EM_cath,2)
for i = 1:numcath plot3(raw_EM_cath(i).cath(8:end,1),raw_EM_cath(i).cath(8:end,2),raw_EM_cath(i).cath(8:end,3)) end
I'm attempting to make a simple plot that will plot a 3D line. I need it to plot all 12 needles (catheters here) but I'm not exactly sure how to iterate over each. My syntax may be off as I've never coded before. How can I fix this? Thanks!
댓글 수: 2
Robert Fennis
2017년 8월 23일
You might very well not have to. Can you elaborate more on what kind of data you have, in what variable name and exactly which plot function you attempt to use?
Anna-Kate Hard
2017년 8월 23일
답변 (1개)
Star Strider
2017년 8월 23일
편집: Star Strider
2017년 8월 23일
Without your data I can’t completely troubleshoot your code.
This should get you started:
numcath = size(raw_EM_cath,2);
figure(1)
hold on
for i = 1:numcath
plot3(raw_EM_cath(i).cath(8:end,1),raw_EM_cath(i).cath(8:end,2),raw_EM_cath(i).cath(8:end,3))
end
hold off
grid on
xlabel('X')
ylabel('Y')
zlabel('Z')
view(45, 30)
EDIT —
Your ‘xyz continuous plotted.fig’ appears to be plotted correctly. I would add the grid on call and axis labels.
댓글 수: 3
Anna-Kate Hard
2017년 8월 23일
Jan
2017년 8월 23일
@Anna-Kate: If you provide the complete error message, the readers do not have to guess, which line is concerned.
Star Strider
2017년 8월 23일
@Anna-Kate Hard — I tested my code with a 3D matrix, since I do not have your data. My code works correctly as far as I can test it.
@Jan — Thank you!
카테고리
도움말 센터 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!