MATLAB: Plot3 with different length of vectors

matlanmeshplotplot3surfvectors

I have 3 parameter. Error, SNR, Weights
1. Error is a 3x9 data
2. SNR = [15,30,50]
3. Weights = 0.1:0.1:0.9
So basically, i want to see the evolution of my error with respect to the weight and SNR
I have done this with surf. but I want to try plot3, unfortunaley it doesnt work when length of vectors are unequal. is there a work around this?

Best Answer

You need to specify the x (SNR) and y (Weight) coordinate for each z-value (error). Since z is a matrix, x and y need to be matricies of the same size.
SNR = repmat([15 30 50]', 1, size(error,2)); %note the transpose
Weight = repmat(0.1 : 0.1 : 0.9, size(error,1),1);
plot3(SNR, Weight, error)