Hi i wanted to generate a single axis graph (dont know if this is called a graph exactly) in matlab something like this
In the above image the numerical values represent time ( 1 till 23) min and the vertical thin black lines represent event A . Some of the vertical black lines have a red circle on top denoting occurrence of an event B along with the event A. Is it possible to generate such a simulated image in matlab ? If so what keywords should i look for. Any suggestions to get me quickly started on generating such a graph/Simulation. (Note: I havent actually used matlab a lot.. certainly never generated graphs in it)
You probably want a stem graph, and then do something like:
stem(event_times, ones(size(event_times));
You can overlay multiple graphs to get the red circles, etc.
Related
I have to do the scatter plot of a 2-dimensional region in Matlab.
The collection of the points (x,y) that should be included in the scatter is obtained by running a computationally intense code. As a result, this is the scatter that I get
I don't like the picture because in principle there should be no white dots (i.e., spaces among the scatter dots) inside the blue region. The white dots are there because, given that the points to be included in the scatter are obtained by running a computationally intense code, as a result I get a very coarse grid of points to plot.
I tried to cheat by increasing the size of the scatter dots but the result is even worse as the region looks more and more waving on the borders.
Is there anything I could do to "manually" fill the white spaces inside the blue area? Other ideas?
If you want the whole region to be filled, a patch object might be better suited to your needs. Not knowing how you're generating the points, that might be easier said than done. If you are systematically searching the whole area or something like that, it shouldn't be too hard to identify the edges, or define small patches for each square space on the plot.
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 can make I tiny sticks like those shown in red surroundings in the plot below? I used a binary vector of anomalies (1 if anomaly 0 if not) and used plot function, but rather I' d like to see spikes like in the figure.
These sticks correspond to anomaly indicators in the data such as discontinuities (as can be seen in the plot). I'd also like if you could propose good alternative visualizations.
Matlab allows drawing rectangles on the plot.
I'm trying find all straight lines in an image which is border. for example,stamps have four edges and I have already find those edges by edge function in MATLAB. But there is a problem that they are not real straight line. so I need to use line fitting to get all four borders. But polyfit function can only fit one line at one time. Is there any solutions that can fit all lines at one time.
for example:here I upload some pictures,the image with red lines is what I want. Please be ware I need four separate lines.
Judging from the image you won't be trying to smooth some lines, or fill in the gaps. Instead it looks more like you need to put your image in the smallest possible box.
Here is an algorithm that you can try:
Start from all 4 corners.
'walk' one of the corners inwards and determine if all points are still within four corners
If so, save this corner and go to step 2, else go to step 2
Keep repeating step 2 and 3 till you have a steady solution.
Are you trying to get rid of the perforations? In that case I would suggest using thresholding to segment out dark areas of the image, and then using regionprops to get their bounding boxes. Then you can figure out the largest rectangle that excludes them.
I have a task to draw electrostatic field between
two electrodes( at given sizes and shape ),
what i have now is that i draw the electrodes with area plot (area(elect_x,elect_y))
the graph looks like this:
------------------.---
|..
.---. |..
|...| |..
.----....| |..
|........| |..
----------------------
and now i would need to draw inside this probably a mesh, showing the field.
Is there any way to do it, or i´m on a wrong way?
Thank you very much for every guide
First, if you want to overlay multiple plots in the same axes, type
hold on
before you plot the second graph (or set the 'NextPlot' property of the axes to 'add'), so that the first plot is not erased when the second one is drawn.
To show electrical field, you may want to have a look at quiver, so you can visualize both direction and strength of the fiels. Also check out is demo of quiver to get and idea how you could show field strength with colors.