Adding reciprocal second x axis to Matlab plot - matlab

Good afternoon SO,
I'm producing plots of (1 / temperature) against stuff, and would like to also add a temperature axis at the top of the graph to allow temperature ranges to be more readable. I found something called plotxx.m, but the problem I see is that the top axis isn't going to be a linear one, but a funky reciprocal scale. How could I achieve this?
Thanks

Related

Offset lineplot from Y-axis

I am working with a data stream and for different time points in this stream I have density estimates over a fixed set of X values.
Each of these sets of estimates would look something like this
I'd like to plot multiple curves like this sideways, similar to how it's done in this answer
I've looked through the documentation regarding plotting but didn't find a straight-forward solution for it.
While it's easy to turn such a plot sideways by simply switching the axes, I didn't find a possibility to offset this from the Y-axis
Does anyone have an idea how to tackle this?
Instead of plotting
plot(x,y)
plot
plot(k+y,x)
where k is the location of the plot along the x axis (2 or 4 in your example).

Getting a cross-section from power-spectrum

I am currently trying to use spectral-methods to analyse topographic landscapes.
When i FFT the landscape and plot the power-spectrum. From the power-spectrum an orientation of the structures in the landscape can be found.
2D power-spectrum:-
In this power-spectrum, i would like to make a cross-section.
This is easy when the peak amplitude orientation is along the x or y-axis.
But for this area (and others), this is not the case.
Cross-section from another area - orientated along the y-axis:-
My problem is i want to make a cross-section along the peaks in 1, and i just cant seem to figure it out how.
If anyone could point me towards some solution for this. Been stuck here for a couple of days now.
Edit 1
I would like the cross-section, to be a line along the peak orientation.
Edit 2
Improved the first image to show where i want my cross-section
My solution was, as GameOfThrows suggested:
Pick 2 (or more) points on the orientation i want
used Least squares on the points to create the line
Setup a meshgrid for the interpolation.
Use the interp2 function on the new line.
define a proper axis for the section
In my final cross section i ended up having multiple lines in it, that way i was sure to hit the max amplitudes.
i was a little with the answer to my question, but i have been busy :)
You can use ginput built-in matlab function to store 2 (x,y) coordinates of your power spectrum and then use this values to delimit a profile to be interpolated.

Suggestions on plotting 3 1-Dimensional variables

I have taken readings on my software defined radio. I have three quantities, frequency, power and error rate. I would like to keep frequency on my x-axis as the latter quantities are measured with respect to frequency. Now I need to plot them on a single curve so that i can see frequency vs power and frequency vs error rate in one shot. I have been looking at matplotlib for quite some time but I see the 3d scatter plots and they seem to not convey the picture i want. So my question is
Is 3d plot useless in my case and I better plot 2 graphs and join the y axes of both graphs together so that I could see both the graphs on top of each other.
Is there a way in python or matlab such that you plot a 3d curve and then if you move the cursor you can see frequency vs power and if you move the cursor the other way you can see frequency vs error rate.
Any other ideas on how i can represent my readings better will be helpful.
When two sets of data share the same dependant variable (x-axis), it is common in scientific literature at least to plot them both in the following manner to save space:
This is preferred to twining the xaxis which can cause confusion for some people. It works especially well if features are to be compared.
This plot was generated using:
import pylab as py
x = py.linspace(0,10,1000)
y = py.sin(x)
z = py.sinc(x)
ax1 = py.subplot(211)
ax1.plot(x,y)
ax1.set_xticklabels([]) # Remove the xticks from the top figure
ax1.set_yticks(ax1.get_yticks()[1:]) # Stops the y axis overlapping
ax2 = py.subplot(212)
ax2.plot(x,z)
py.subplots_adjust(hspace=0.0)
py.show()
I believe there is a better way to remove the xticklabels but I can't remember it at the moment. Be careful not to just py.set_xticks([]) as if you then ask for a grid the top plot has no ticks.

Overlapping data points and spacing

I have a set of data that I plot but the points on the graphs are so closed to each other that you can't see them well nd neither their values because even when I zoom in I can't get to them all. Now what I want to do is to space them out without changing their actual values on the graph. Is the a function or any other ways to do that? I've tried changing the axis and the scale but it didn't help. Mostly those points are in the Y direction. Please help What I really mean is though these points are closed to each other I'd like to create and interval between them so they don't pile up on each other
You can make the vector you are trying to plot to be more sparse taking points after some defined intervals:
plot(x(1:10:end),y(1:10:end))
In this example, I plotted each tenth point. Does it help?

Calculating acceleration peak from velocity

I am trying to convert an array of velocity values to acceleration values. I understand that acceleration is the integral of velocity, but don't know how to acheive this. I am using MATLAB, so if anyone can offer a solution in this language, I would be very grateful! See the graph below:
The yellow line plots the velocity and the vertical dotted lines show the peaks and troughs of that waveform (peaks and troughs found using peakdet). The green horizontal stuff in the middle is unrelated to this question.
What I am trying to isolate is the steepest part of the large downward slopes on the curve above. Can anyone offer any advice on how to calculate this?
P.S. I am aware that quad() is the function used to integrate in MATLAB but don't know how to implement it in this situation.
Acceleration is a derivative of velocity.
If your velocity values are stored in v, you can get a quick numerical derivative of v with
a = diff(v)
Be aware that if v is a real rather than synthetic signal, a is likely to be pretty noisy, so some smoothing may be in order, depending on how you're going to use it.