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
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
Anna-Kate Hard il 23 Ago 2017
My input data is 3D coordinates from an electromagnetic tracker-which is placed in a needle. I have a function that I call here ('raw_EM_cath') given to me by someone else that gives the raw data from our tracking system. I plotted it myself by using plot3 and inputting some coordinates by hand. I've been told I could make a function that would plot for me. I just don't know how to do this. I would like to write a simple function that will take the raw data and make a 3D plot like the one I made before (attached). I hope this clarifies!

Accedi per commentare.

Risposte (1)

Star Strider
Star Strider il 23 Ago 2017
Modificato: Star Strider il 23 Ago 2017

0 voti

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
Anna-Kate Hard il 23 Ago 2017
When I attempt to run it I get this error code:
Error: File: plot_EM_cath.m Line: 7 Column: 4 Expression or statement is incomplete or incorrect.
Jan
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
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!

Accedi per commentare.

Richiesto:

il 23 Ago 2017

Commentato:

il 23 Ago 2017

Community Treasure Hunt

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

Start Hunting!

Translated by