MATLAB: Plotting 2 figures into 2 axes, in a GUI - matlab

I have 2 figures generated that show a 3D cube, and one that shows a net. I have associate these with two axes in a GUI using this:
axes(handles.cube);
axes(handles.net);
What I do not understand is how to transfer the figure into each one.
This is probably very simple, I'm very new and very inept with this piece of software- so any advice is greatly appreciated.

I am not sure if this is what you are looking for, but you can use subplot for plotting two different axes in one window, if this is what you desire:
https://de.mathworks.com/help/matlab/examples/displaying-multiple-plots-in-a-single-figure.html

Related

Arraging multiple 3D plots

I have created 6 3D plots that I need to include in a research paper. However, I need to all the plots in a grid.
I've been trying the function subplot but all my plots are combining instead of forming a grid. I have tried setting nrows to various numbers but it does not change the layout. Any ideas on how to fix this? Or other functions that may serve the same purpose?
Shows the function for 1/6 plots, then the subplot function. to the right is the output:

Irregular scaling of MATLAB figure axes

During my work, I got the figure shown below
It is clear that it turns out to be a mess below 5 on the y-axis. What I want to do, is to "expand" the y-axis only in the range from 3 to 5 such that the lines are separated and can be clearly distinguished.
I tried using set(gca, 'Xtick', [0 1 2 3:.5:5 5:25]) but this didn't help at all.
Any hint is appreciated.
What I got is as shown in the figure below:
Since I am getting my data through iterative loops and even sub-loops, I couldn't manage to get the desired figure using "inset plot", it got so complicated. However, what I did is simply that I had two MATLAB figures, the original one and another copy of it with a zoom-in of the y-axis from 3.5 to 5, then I copied the zoomed one to the original one and that's it.
This practice is better than using power point or paint to get the figure since doing so in MATLAB gives MUCH more flexibility in terms of editing the two figures, resizing them, axes labeling and so on.
Hope this would help someone else.

MATLAB: Digitizing a plot with multiple variables and implementing the data

I have 8 plots which I want to implement in my Matlab code. These plots originate from several research papers, hence, I need to digitize them first in order to be able to use them.
An example of a plot is shown below:
This is basically a surface plot with three different variables. I know how to digitize a regular plot with just X and Y coordinates. However, how would one digitize a graph like this? I am quite unsure, hence, the question.
Also, If I would be able to obtain the data from this plot. How would you be able to utilize it in your code? Maybe with some interpolation and extrapolation between the given data points?
Any tips regarding this topic are welcome.
Thanks in advance
Here is what I would suggest:
Read the image in Matlab using imread.
Manually find the pixel position of the left bottom corner and the upper right corner
Using these pixels values and the real numerical value, it is simple to determine the x and y value of every pixel. I suggest you use meshgrid.
Knowing that the curves are in black, then remove every non-black pixel from the image, which leaves you only with the curves and the numbers.
Then use the function bwareaopen to remove the small objects (the numbers). Don't forget to invert the image to remove the black instead of the white.
Finally, by using point #3 and the result of point #6, you can manually extract the data of the graph. It won't be easy, but it will be feasible.
You will need the data for the three variables in order to create a plot in Matlab, which you can get either from the previous research or by estimating and interpolating values from the plot. Once you get the data though, there are two functions that you can use to make surface plots, surface and surf, surf is pretty much the same as surface but includes shading.
For interpolation and extrapolation it sounds like you might want to check out 2D interpolation, interp2. The interp2 function can also do extrapolation as well.
You should read the documentation for these functions and then post back with specific problems if you have any.

How to combine different figures in a Matlab script?

I am workin on a some sort of System test wherein i have a set of readings in the form of a .mat file.
It has a structure in the .mat file with one field as Measurement. It has several Arrays(e.g air mass flow, velocity, carbon content) which further have fields like time and value.
From these, I Need to plot the velocity and the air mass flow against time. For that i wrote the following command which gave me the corresponding plots:
plot(Measurement.(Measurement.air_mass_flow.time),Measurement.air_mass_flow.value)
plot(Measurement.(Measurement.velocity.time),Measurement.velocity.value)
Now i Need to create a script in matlab wherein i can get both the curves one under the other i.e. on the same page. Can anyone help in the Approach i should procede with ?
ok now i will further extend my question.
I have two fields as velocity and acceleration. I Need to plot it on the same curve with grids on for the comparison. But the y axis for both are different.
the velocity y-axis is: (0:20:120), which should be displayed on the left side and the acceleration y-axis is: (0:2:12) which should be displayed on the right side.
i wrote the following code for this:
plot(Measurement.(Measurement.VehV_v.time),Measurement.VehV_v.value)
grid on
set(gca,'xtick',[0:500:2000])
set(gca,'ytick',[0:20:120])
hold on
plot(Measurement.(Measurement.accel_w.time),Measurement.accel_w.value)
grid on
set(gca,'xtick',[0:500:2000])
set(gca,'ytick',[0:2:12])
Do i Need to write a function for that as i am directly reading the values from the structure.
plotyy() also doesnt seem to work
But the axis are not matching and the graph for acceleration is very small. Could anyone help me out with this ?
I also want to add a Picture of the Graphs here but unfortunately there is some error here. I hope the question is clear without the Picture.
Yes you can use the subplot command, e.g.:
figure
subplot(1,2,1)
plot(Measurement(Measurement.air_mass_flow.time),Measurement.air_mass_flow.value)
subplot(1,2,2)
plot(Measurement.(Measurement.velocity.time),Measurement.velocity.value)
You can use help subplot on Matlab for further details or have a look at this:
https://www.dartmouth.edu/~rc/classes/matlab_graphics/Matlab-subplots.html

MATLAB Graphing plots with axes

I have been trying to Create a program with the GUI in MATLAB. When I try to plot information with AXES I can not figure out how to do it. I know about the function plot, but I need to be able to re-size and move the plot around in the figure so I can make room for the input uicontrol. I am not sure what to do. Please help.
There are a couple of different ways to tackle this problem. But the way I always choose to do so, is:
hold on:
plot(...), xlim([xmin xmax), ylim(ymin ymax])
This should set your bounds on the axis.
I don't have Matlab at hand right now, but try the following:
To set size of the plot axes inside the figure window use
set(gca,'Position',[left bottom width height])
see Mathworks' site on axes properties