Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I would like to add some arrows to a 3D surface plot to indicate important directions, similar to this one (from povray)
Different colors would be great and a threedimensional letter like the X in the image even more.
The function 3D arrow plot at the MATLAB file exchange actually does this:
Meanwhile https://ww2.mathworks.cn/matlabcentral/fileexchange/14056-arrow3 turned up, which might be even better but I haven't tested it...
I used something similar to your approach thta could be a start for you: here is an example of the code:
q=[0 1 0 1];
q=qnorm(q);
x = q(1) / sqrt(1-q(4)*q(4))
x =
0
y = q(2) / sqrt(1-q(4)*q(4))
y =
1.0000
z = q(3) / sqrt(1-q(4)*q(4))
z =
0
quiver3(0, 0, 0, x, y, z)
It is a quaternion that I normalize and convert to axis components in order to draw it 3D. I also would like to be able to draw it 3D like the picture you posted.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I am new to MATLAB, my problem is I created a triangle, now requirement is to gather all the x,y coordinates on three sides of triangle in order to find the angles to the starting point (0,0).
My approach is
side_1=[linspace(0,2,100),linspace(1,1,100)]
side_2=[linspace(2,0,100),linspace(1,5,100)]
side_3=[linspace(0,0,100),linspace(5,1,100)]
all_coordinates=(side_1, side_2, side_3)
The 4th line of the above code failed, I need make a matrix that contains all x,y coordinates in order to calculate angles that every points face to (0,0) by atan function. Looking for advice.
The first three lines of you code created three 1x200 row vectors. I presume you are trying to combine them into a single matrix with dimensions 3x200. In that case use:
all_coordiantes=[side_1; side_2; side_3]
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm trying to make a confusion matrix for some classification problem.
So far, I've managed to make a 10 by 10 matrix that stores the accuracy of my estimation for classification problem.
Now I want to make a 10 by 10 square image(?) that has a darker color when the number in that location of the matrix has a higher number. (Ranges from 0 to 100)
I've never done graphics with Matlab before.
Any help would be greatly appreciated.
Thanks.
I would use image. For example:
img = 100*rand(4,4); % Your image
img = img./100*64; % The `image` function works on scale from 0->64
image(img); % or `image(img')` depending on how you want the axis
colormap('grey'); % For grey scale images
axis equal; % For square pixels
Or for inverted colours you can change the one line to:
img = 64-img./100*64;
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want to create a grid in Matlab, I want mark some cell as free , some(blacks) as obstacle, and mark one cell as start and another cell as end point and some as path, like below image,how can I achieve this in Matlab?
To get you started, here's how to create something that looks like the image you included using pcolor.
A = ones(11,11)
A(5,1:3) = 0;
A(8:10,2:3) = 0;
A(5:7,6:7) = 0;
A(1:3,8:10) = 0;
pcolor(A)
colormap(gray(2))
% To flip the vertical axes, uncomment next line
%axis ij
For start and goal
patch([1,2,2,1],[2,2,3,3],[0.5 0.5 1]) % [r g b] values
text(1.25,2.5,'Start')
patch([10,11,11,10],[10,10,11,11],'g')
text(10.25,10.5,'Goal')
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Please If anyone can give a hint on drawing this in matlab
( I am not asking for the actual code but just a hint....)
Hard do give a hint, as it is just one line of code.
rectangle('Position',[1,2,5,6])
To actually see the rectangle you need to set the axes limits:
axis equal
xlim([0,8])
ylim([0,9])
Regarding your comment: have a look at this answer which gives a little introduction into the core graphics objects you're lookling for.
Core Graphics Objects
Core graphics objects include basic drawing primitives:
Line, text, and polygon shells (patch objects)
Specialized objects like surfaces, which are composed of a rectangular grid of vertices
Images
To draw an arbitrary figure you can use plot. For example, this draws a trapezoid:
x = [1 7 4 2 1]; %// x coordinates of vertices
y = [1 1 3 3 1]; %// y coordinates of vertices
plot(x,y); %// do the plotting
axis([0 8 0 4]) %// set axis limits
As you se, you specify the vertices and plot (in its default behaviour) joins them with straight lines. You need to specify the first vertex again as a last vertex to close the polygon.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I need to plot points in 3D in MATLAB. For example, look at this image:
The background represents a plane, and the color of each
point is dependent on its Z value. It is a 2D plot,
but if you plot this in 3D you should get a plane and points.
I did not create this image, and I wonder how to plot like this.
I need to make the colors of the points dependent on their Z value and
plot in 2D, or if I plot this in 3D how do I plot points in 3D?
THanks
use scatter3
scatter3(x, y, z, 'ob');
See doc here.