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!