Save plot to a matrix in Octave/MatLab [duplicate] - matlab

This question already has answers here:
Save a plot in Matlab as a matrix [duplicate]
(2 answers)
Closed 6 years ago.
I wish to save a plot created in octave in a matrix
x=[0:10];
y=[0:10];
figure(1);
plot(x,y);
How can I save this plot into a matrix (or a 3D array, assuming it is RGB). To explain in a different way. Lets say there exist an image "img.jpg" in the working directory. Than i can open it as a matrix
A=imread("img.jpg");
How can one accomplish the same, having the plot saved in the matrix A?

Did you mean loading an image stored as a matrix into a variable? If so, You can use
A = load('img.mat')

Related

plotting deviation along all the values of x? [duplicate]

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)

How to store all pixel values of an image in either in an array or in a vector using matlab [duplicate]

This question already has an answer here:
Image Pixel values
(1 answer)
Closed 6 years ago.
I want to store all pixel values of an image in either in an array or in a vector using matlab. Please suggest me how can I do it?
Probably what seems is you want to store the image in 1D, which can be done as:
I = imread('cameraman.tif');
I_1D = I(:);
you also take the transpose of this vector as I_1D = I(:)';

How to get Matrix from row-major vector in Matlab? [duplicate]

This question already has answers here:
Reshaping of Array in MATLAB
(3 answers)
Closed 7 years ago.
I have the following matrix:
50,60,55,67,70
62,65,70,70,81
72,66,77,80,69
I turn now the matrix into a vector but in row-major. This gives the following vector:
50,60,55,67,70,62,65,70,70,81,72,66,77,80,69
Now I would like to turn this vector into the same matrix as above. The problem is that reshape(matrix,[3,5]) does not work because Matlab operates column-major.
How can this be done efficiently (for large matrices)?
To solve this, use
reshape(matrix,[5,3]).'
First using reshape with row and column dimension swapped, you get a matrix with the right order but transposed, then using transpose you get the right output.
Having the control systems toolbox, you could also use vec2mat

How to plot from adjacency matrix? [duplicate]

This question already has an answer here:
Draw network or graph from matrix in matlab
(1 answer)
Closed 7 years ago.
I have an adjacency matrix and corresponding labels. I need to plot a network with weighted edges and different colors based on labels. I found there is gplot function in matlab, but it is not created weighted edges. Does anyone know any toolbox or function or something I can use?
There is a tool called wgPlot by Mike Wu that will allow you to plot weighted adjacency graphs easily.
wgPlot by MikeWu
Note that the edges are not labeled textually, but by a color scale.

3d plots in matlab based on a matrix [duplicate]

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