I'm using the mArrow3 function, but it does not work always, ussually not. The code:
hold on;
mArrow3([0 0 0],[1 0 0],'lineWidth',0.0000002,'color','red','facealpha',0.05);
mArrow3([0 0 0],[0 1 0],'lineWidth',0.0000002,'color','red','facealpha',0.05);
mArrow3([0 0 0],[0 0 1],'lineWidth',0.0000002,'color','red','facealpha',0.05);
hold off
Could you please give me any hint? It doesn't show any errors, just doesn't appear for most of the time. But on it's own it just works fine.
One more question, do you know how to put titles to X, Y and Z directions? I mean appearing it just next to the arrows.
Now about the text command. I need to put three different texts in three different places - with just text command I put everywhere the same text. Is there any similar command to the text command?

2 commentaires

Jan
Jan le 7 Mar 2017
Franta Cymorek
Franta Cymorek le 7 Mar 2017
I have downloaded the function and it's not working properly, that's the reason I am asking here.

Connectez-vous pour commenter.

 Réponse acceptée

Jan
Jan le 7 Mar 2017

0 votes

What exactly does "most of the time" mean? Please post some code, which reproduce the problem.
The lineWidth of 0.0000002 is very small. My first idea is, that the arrow is not visible, because it is far to thin. Did you try it with something less slender?

16 commentaires

Franta Cymorek
Franta Cymorek le 7 Mar 2017
Modifié(e) : Franta Cymorek le 7 Mar 2017
I would have to upload all of the codes and functions here, would take forever. I have a GUI in Matlab, I load an Excel sheet, I have 3 axes where points to be plotted in 3D are chosen with a PC mouse, then a button is pressed and the 3D curve is created. The code I have uploaded here is what is used using the mArrow3 function. Btw, I know it's not explained well, but as already written above, it would take forever upload all of the codes here. The question is meant generally.
Works only for one certain plot, not for other plots.
Jan
Jan le 7 Mar 2017
I understand. I would like to help you and therefore I ask for a piece of code, which reproduces the problem. Otherwise creating an answer requires to guess, what the problem is.
You can set a breakpoint in the line, which contains the mArrow3 command and save the input values as well as the axes properties in a MAT file. This might help to reproduce the output without the need to post your complete code.
Did you try to increase the linewidth already?
Franta Cymorek
Franta Cymorek le 7 Mar 2017
Modifié(e) : Franta Cymorek le 8 Mar 2017
The code:
function [pointsQRS, pointsP, pointsT] = VCG (pointsQRS,pointsP,pointsT)
%pro popis principu funkce viz VCG_QRS
figure(2)
hold on
for i=2:size(pointsQRS,1)
if mod(i,2)==0
QRS=plot3(pointsQRS([i-1:i],1),pointsQRS([i-1:i],2),pointsQRS([i-1:i],3),'-k');
else
plot3(pointsQRS([i-1:i],1),pointsQRS([i-1:i],2),pointsQRS([i-1:i],3),'-g');
end
end
for i=2:size(pointsT,1)
if mod(i,2)==0
T=plot3(pointsT([i-1:i],1),pointsT([i-1:i],2),pointsT([i-1:i],3),'-b');
else
plot3(pointsT([i-1:i],1),pointsT([i-1:i],2),pointsT([i-1:i],3),'-g');
end
end
for i=2:size(pointsP,1)
if mod(i,2)==0
P=plot3(pointsP([i-1:i],1),pointsP([i-1:i],2),pointsP([i-1:i],3),'-r');
else
plot3(pointsP([i-1:i],1),pointsP([i-1:i],2),pointsP([i-1:i],3),'-g');
end
end
view(3)
grid on
hold on;
mArrow3([0 0 0],[1 0 0],'lineWidth',0.002,'color','red','facealpha',0.05);
mArrow3([0 0 0],[0 1 0],'lineWidth',0.002,'color','red','facealpha',0.05);
mArrow3([0 0 0],[0 0 1],'lineWidth',0.002,'color','red','facealpha',0.05);
hold off
Yep, I have tried it, didn't work out. What is wrong with the code? As well, do you know how to put a comment to each tip of an arrow? I have tried the text command, but didn't wokr. I mean 3 different comments.
Jan
Jan le 8 Mar 2017
Modifié(e) : Jan le 8 Mar 2017
Perhaps the ploted data have a magnitude of 1e6, such that the arrows with the length of 1 is too tiny to be seen? An opaquness or 5% is very light also. Try this:
drawnow;
xExt = abs(diff(get(gca, 'XLim')));
yExt = abs(diff(get(gca, 'YLim')));
zExt = abs(diff(get(gca, 'ZLim')));
mArrow3([0 0 0],[xExt / 10, 0, 0], 'lineWidth', 2,'color','red','facealpha', 0.5);
mArrow3([0 0 0],[0, yExt / 10, 0], 'lineWidth', 2,'color','red','facealpha',0.5);
mArrow3([0 0 0],[0, 0, zExt / 10], 'lineWidth', 2,'color','red','facealpha',0.5);
Well, something remains strange. The output is not what I expected. But at least it is visible.
Franta Cymorek
Franta Cymorek le 8 Mar 2017
Modifié(e) : Franta Cymorek le 8 Mar 2017
Works a lot better now, but still not perfectly.
The lines of the arrows are too much short, and, it's not atteched to the beginning. Is there a way to solve it? How can I determine attaching it to the beginning/start point of the plotted data (no matter which data are chosen)? And what is the name of function to make the lines longer where the tipes are attached?
Jan
Jan le 8 Mar 2017
You can set the startpoint by defining the first input of mArrow3.
mArrow3 has many 5 star votes. But The result in your picture are looking strange. Reading the help section I see only commands for the "stemWidth" and "tipWidth".
Perhaps it is worth to try one of the many other arrows published in the FileExchange: https://www.mathworks.com/matlabcentral/fileexchange/?utf8=%E2%9C%93&term=arrow+3d
Franta Cymorek
Franta Cymorek le 8 Mar 2017
Modifié(e) : Franta Cymorek le 8 Mar 2017
The lenght is solved out. Could you please give me last one hint about positioning text next to the tips? I mean 3 different texts, I have tried the text command, but this is not the right one for it. For the text positioning I know it's not a part of this function.
Jan
Jan le 8 Mar 2017
Modifié(e) : Jan le 8 Mar 2017
The position of the tips are stored in the 2nd input. Therefore I assume it can be solvwed by the text() command:
text(1.1, 0, 0, 'x'); % EDITED: X,y,z instead of [X,Y,Z]
text(0, 1.1, 0, 'y');
text(0, 0, 1.1, 'z');
I've moved the string a little bit away from the tips to avoid a collision. Why do you think, that text() does not help?
Franta Cymorek
Franta Cymorek le 8 Mar 2017
Modifié(e) : Franta Cymorek le 8 Mar 2017
I have tried your code and didn't work out, even it deleted the xlabel, ylabel and zlabel. Looked like the second picture.
Then I have tried this code:
text([1, 0, 0],[0 0 0], 'x');
text([0, 1, 0],[0 0 0], 'y');
text([0, 0, 1],[0 0 0], 'z');
And it looked like the first picture, even the text is so small. That's is why I thnik it's not suitable for it, because it behaves weird all the time. As well the text gets overlaped.
Jan
Jan le 8 Mar 2017
Modifié(e) : Jan le 8 Mar 2017
Sorry, there was a typo in my code. You need something like:
text(1.1, 0, 0, 'x'); % Not text([1.1, 0, 0], 'x')
And of course replace the values by the positions of the tips of the arrows.
Use the 'FontSize' to adjust the size.
Franta Cymorek
Franta Cymorek le 8 Mar 2017
Modifié(e) : Franta Cymorek le 8 Mar 2017
In one picture it just works perfectly, no overlaping. But second picture, it ovelaps.
This is the modified code you provided and I used:
drawnow;
xExt = abs(diff(get(gca, 'XLim')));
yExt = abs(diff(get(gca, 'YLim')));
zExt = abs(diff(get(gca, 'ZLim')));
mArrow3([0 0 0],[xExt / 1, 0, 0], 'lineWidth', 2,'color','red','facealpha', 0.05);
mArrow3([0 0 0],[0, yExt / 1, 0], 'lineWidth', 2,'color','red','facealpha',0.05);
mArrow3([0 0 0],[0, 0, zExt / 1], 'lineWidth', 2,'color','red','facealpha',0.05);
text(1, 0, 0, 'Vx','FontSize',12);
text(0, 1, 0, 'Vy','FontSize',12);
text(0, 0, 1, 'Vz','FontSize',12);
I have no idea why it gets overlapped, only as you can see, it works perfectly in one case. Only different data were used. Do you have any experience with this case?
Jan
Jan le 8 Mar 2017
It depends on the sizes of the axes: While one axes has sizes of the magnitude of 1000, the other is in the range of 1. If the tips of the arrows are at e.g. [xExt,0,0], the location of the text lable should be there also.
Franta Cymorek
Franta Cymorek le 8 Mar 2017
Exactly what I needed! Thank you!
Franta Cymorek
Franta Cymorek le 8 Mar 2017
Modifié(e) : Franta Cymorek le 8 Mar 2017
A question a little bit off the topic, is there a way, to change the color of an arrow and cone separately?
Jan
Jan le 9 Mar 2017
I assume that this works. The code of mArrow3 does not look trivial, but with the debugger you can examine, where what is drawn.
Franta Cymorek
Franta Cymorek le 9 Mar 2017
Yes, this works exactly how I wished it. Is there any link describing how to change the cone color and so on?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by