Hello. I want some suggestions on how to my code a bit more versatile. I altered the SpectrogramData example for a discrete series of XYZ data simply by coupling the x and y to the discrete values of my Data->ZData vector.
{
public:
...
virtual double value(double x, double y) const
{
double dx, dy;
dx = (Data->Xdata.last()-Data->Xdata.first())/(Data->Xdata.size()-1);
dy = (Data->Ydata.last()-Data->Ydata.first())/(Data->Ydata.size()-1);
int i = (x-Data->Xdata.first())/dx, j = (y-Data->Ydata.first())/dy;
return Data->Zdata[j][i];
}
...
}
class SpectrogramData: public QwtRasterData
{
public:
...
virtual double value(double x, double y) const
{
double dx, dy;
dx = (Data->Xdata.last()-Data->Xdata.first())/(Data->Xdata.size()-1);
dy = (Data->Ydata.last()-Data->Ydata.first())/(Data->Ydata.size()-1);
int i = (x-Data->Xdata.first())/dx, j = (y-Data->Ydata.first())/dy;
return Data->Zdata[j][i];
}
...
}
To copy to clipboard, switch view to plain text mode
This type of resampling works well if I am operating with linearly sampled data (XData and YData are equidistant). How can I improve this algorithm for a series of non-linearly scaled data (i.e. XData = [1 10 20 50 70 100 1000])?
Bookmarks