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.
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 5 years ago.
Improve this question
I have seen a plot in one page. I wanted to recreate a similar plot I searched for the code but could not find the code for the plot. Attaching the plot with this of which I wanted to generate in MATLAB
As an example, here's a plot for a dampened sine curve:
A=10;
f=1000;
n=5;
T=1/f;
t=[0:T/100:n*T];
s=A*exp(-t*1000).*sin(2*pi*f*t);
% Here is the bit you'd be interested in:
plot(t,s,'b-','lineWidth',2) %'b-' is blue line.
xlabel('time (s)')
ylabel('amplitude (v)')
set(gca,'linewidth',2)
grid on
ax = gca;
ax.XGrid = 'off';
ax.YGrid = 'on';
set(ax,'GridLineStyle','--')
Change the formula or data to achieve desired plot shape.
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 compute histogram of oriented gradient on my image. But I don't want to divide the image to regular square blocks. I'm going to divide the image to uniform log polar bins(like bins in shape context or bins like here ) and then on each bin(block) the histogram of gradient with 8 orientation is computed.
But
1) I don't know how to divide the image to log polar bins. Can I use shape context? Or even the above link for partitioning to these bins?
2) how can I compute HOG on this bins since available codes(in matlab, OpenCV and EmguCV) use square bins? I have no idea.
What you are describing sounds pretty much like the C-HOG (circular HOG) features in the original HOG paper. The only difference wrt typical hog is the shape of the bins. I think it would be best to:
iterate over the pixels
calculate the circular bin number for each pixel
add the contribution of the gradient at the pixel to the histogram corresponding to the bin number
A good starting point would be the pseudo-matlab-code in this answer: https://stackoverflow.com/a/10115112/1576602
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.