Plot in for loop
Mostra commenti meno recenti
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 Commenti
Robert Fennis
il 23 Ago 2017
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
il 23 Ago 2017
Risposte (1)
Star Strider
il 23 Ago 2017
Modificato: Star Strider
il 23 Ago 2017
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 Commenti
Anna-Kate Hard
il 23 Ago 2017
Jan
il 23 Ago 2017
@Anna-Kate: If you provide the complete error message, the readers do not have to guess, which line is concerned.
Star Strider
il 23 Ago 2017
@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!
Categorie
Scopri di più su Annotations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!