Question

I have many data need to be plotted as waterfall in matlab. I have more than 10 columns of data, each column represents one data data set. I put all data in a big matrix such that the first data set put in the first row of matrix, the second data set will be in the second row ... etc. After all those data stored in a matrix, I use the waterfall to plot those data. For each column, it contains about 10,000 data points which corresponds to x variable ranged from -5 to 5. But in the waterfall, it shows 0 to 10, 000 instead of -5 to 5 in the x axis. How do I force matlab to show the correct range? thx

mydata = zeros(13, 10000);
mydata(1, :) = ... ;  % first data set
mydata(2, :) = ... ;  % second data set
...
mydata(13, :) = ... ; % last data set
waterfall(mydata)
Was it helpful?

Solution

If you look at the documentation for waterfall (you can do this easily by placing the cursor in the command in your editor and hitting F1), you will see that you can invoke the waterfall command with different syntax . .

% Syntax

waterfall(Z) 
waterfall(X,Y,Z) 
waterfall(...,C) 
waterfall(axes_handles,...) 
h = waterfall(...) 

Rather than just call the waterfall plot with the data Z, supply it with the X and Y range data also. For example . . .

mydata = rand(13, 10000);
Y = 1:size(mydata,1);
X = linspace(-5, 5,size(mydata,2));

waterfall(X, Y , mydata)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top