This question already has an answer here:
How does subplot work and what is the difference between subplot(121) and subplot(1,2,1) in MATLAB?
(1 answer)
Closed 8 years ago.
I'm using MatLab for Image processing. I want to show images and histograms in 4 rows and and 2 columns but I fail to plot them
my code is below
% Show the images
subplot(1,2,1);imshow(I);
subplot(2,2,1);imshow(G);
subplot(3,2,1);imshow(B);
subplot(4,2,1);imshow(L);
% Plot Histograms
subplot(1,2,2);plot(h);
subplot(2,2,2);plot(hG);
subplot(3,2,2);plot(hB);
subplot(4,2,2);plot(hL);
according to the MatLab Documentation subplot(totalNoOfRows,totalNoOfCols,Position);
Positions are
1 2
3 4
5 6
7 8
error free code is here
% Show the images
subplot(4,2,1);imshow(I);
subplot(4,2,3);imshow(G);
subplot(4,2,5);imshow(B);
subplot(4,2,7);imshow(L);
% Plot Histograms
subplot(4,2,2);plot(h);
subplot(4,2,4);plot(hG);
subplot(4,2,6);plot(hB);
subplot(4,2,8);plot(hL);
Related
This question already has answers here:
xaxis/yaxis lines in matlab plot
(2 answers)
How to add a x-axis line to a figure? (matlab)
(6 answers)
Closed 3 months ago.
I want to plot the mean of a data measurement with the standard deviation along the x-axes. I tried using boundedline, but it is not working. I have just one value (y value) with the corresponding standard error to plot across the x values. Can someone know how to do it?
boundedline.m - File Exchange - MATLAB Central (mathworks.com)
This question already has answers here:
Matlab Special Matrix
(2 answers)
Closed 10 months ago.
I want generate matrix of the form:
1 2 3
2 3 4
3 4 5
using MATLAB.
I can make code to generate matrix above:
for i=1:3
for j=1:3
idx(i,j)=i+j-1;
end
end
But, I want use MATLAB built-in function to generate matrix above to simplify my code (I don't want using looping again). Anyone know MATLAB built-in function to generate matrix above?
In MATLABĀ® R2016b and later:
[1:3] + [0:2]'
Old style:
bsxfun(#plus,1:3,[0:2]')
Try using
[1:3; 2:4; 3:5]
This generates a 3 x 3 matrix and simplifies your code down to one line.
This question already has an answer here:
Bilinear image interpolation / scaling - A calculation example
(1 answer)
Closed 6 years ago.
I have (x,y) points and how to find (x1,y1),(x1,y2),(x2,y1),(x2,y2) grid points in the set of data points(xi,yi)...
Have a look at ceil and floor.
They will round up and down a value, thus ceil(3.2) will output 4 and floor(3.2) will output 3. The right combinations of ceil/floor x and y will give all the points you need.
I am getting the plot as shown in the figure in MATLAB after applying some function. On fitting a polynomial, we see that we get a parabolic curve for this curve as shown in the next figure. . Is there any way that I can develop some model that can tell that this graph is a parabolic graph. Or from the values from which this curve is generated, is it possible to comment for the same?
Edit:
Here is my code:
`
clear
tab=csvread('test_cs22.csv',1,0);
x=tab(:,1);
y=tab(:,2);
p=polyfit(x,y,2);
pp=polyval(p,x);
plot(x,y)
hold on
plot(x,pp,'-r');`
I am taking in the input from a csv file that consists of data in this manner.
1 89420
2 64614
3 60377
4 105717
5 111244
6 151984
7 108780
8 273562
9 182516
10 221625
This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
Matlab 3D Matrix Plot
I have a matrix in matlab that I want to plot as a 3D figure.
Suppose the matrix looks like the following:
A=[4 7 8; 2 3 9 ]
This actually means the following data points in x,y,z plane
(1,1,4) (1,2,7) (1,3,8) (2,1,2) (2,2,3) (2,3,9)
I want to plot these values on a 3D graph.
How can I do that?
The function to use is surf(A)
This will plot your points from x = 1:2 and y = 1:3