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 8 years ago.
Improve this question
I have above image with white background. I need to count the circles and get diameter of each circle using morphological, logical and set operations of matlab. Any ideas how to do it?
Use regionprops:
img = imread('http://i.stack.imgur.com/OJidJ.png');
bw = img(:,:,1) < 128; %// convert to logical mask
d = regionprops( bw, 'EquivDiameter' );
d = [d.EquivDiameter]; %// array with diameter of each coin.
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 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 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.