Program for a plot in MATLAB [closed] - matlab

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.

Related

Confusion matrix image in matlab [closed]

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;

Create 2D grid in matlab [closed]

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')

Matlab: How to count? [closed]

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.

image object orientation and rotation using MATLAB [closed]

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 almost 1000 images of similar dataset all of them have black background and an object (skin cancer mole) . Now the problem is clear i.e the objects are in different orientation I want the objects in all images with same orientation.
MATLAB code will be recomended.
Answer found:
Check the two images of skin lesion mole shown below:
We assume that it comes from loop on folder(1000 images) in which they are at:
Code:
% I1= first image
I=imread(I1); %% Image input
BW = im2bw(I,0.004);
%%%%% Getting the biggest region (because if segmentation give unclear results)
[L, num] = bwlabel(BW, 8);
count_pixels_per_obj = sum(bsxfun(#eq,L(:),1:num));
[~,ind] = max(count_pixels_per_obj);
biggest_region = (L==ind);
%%%%%%
%%% getting orientation
s = regionprops(biggest_region, 'Orientation');
data=s.Orientation;
%%% Orientation end
Y = imrotate(I, -data, 'loose', 'bilinear');
figure;
imshow(Y)
%%% Now the rotated image will be shown as
%% Now write the image in any other folder
%% that have all images aligned
imwrite(Y, 'test.jpg');
%% Hope it will save time for other. Thanks

Plot points in 3D in MATLAB? [closed]

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.