# I want vector surface plot

1 visualizzazione (ultimi 30 giorni)
stelios loizidis il 30 Mag 2022
Risposto: Star Strider il 30 Mag 2022
Hello,
I have three vectors: Prices:1X30, Position:1X30 and Quantity:1X30 and I want to do the surface plot. I get the following error:
"Z must be a matrix, not a scalar or vector."
##### 2 CommentiMostra NessunoNascondi Nessuno
KSSV il 30 Mag 2022
As Prices, Position, Quantity are three vectors, you cannot have a surface plot. You need to have one matrix of size 30x30 to have a surface plot.
stelios loizidis il 30 Mag 2022
Do you think it's right to do the 30x30 matrix with these three vectors?

Accedi per commentare.

### Risposte (2)

KSSV il 30 Mag 2022
Prices = 1:30 ;
Position = 1:30 ;
Quantity = rand(1,30) ;
Quantity = repmat(Quantity,30,1) ;
surf(Prices,Position,Quantity)
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

Star Strider il 30 Mag 2022
I am not certain what result you want.
Try this —
Prices = rand(1,30); % Use Actual Vector
Position = rand(1,30); % Use Actual Vector
Quantity = rand(1,30); % Use Actual Vector
Prv = linspace(min(Prices), max(Prices), numel(Prices));
Psv = linspace(min(Position), max(Position), numel(Position));
[Pr,Ps] = ndgrid(Prv,Psv);
Qt = griddata(Prices(:),Position(:),Quantity(:),Pr,Ps);
figure
surfc(Pr, Ps, Qt)
grid on
xlabel('Prices')
ylabel('Position')
zlabel('Quantity')
.
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Price and Analyze Financial Instruments in Help Center e File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by