When creating 3D plot with surf(X,Y,Z); error that Z isn't a matrix.
Show older comments
Hi,
I am attempting to create a 3D surface plot for a chemical equilibrium. I'm trying to do this with the function surf(X,Y,Z). The problem is that no matter what I do, Matlab keeps giving the error that Z isn't a matrix. I don't have a clue how put Z in matrix form. Please help. My code so far:
K=logspace(5,9,100);
DNAtot=1e-8;
TFtot=logspace(-9,-5,100);
[X,Y]=meshgrid(TFtot,K)
TFDNA=((K.*TFtot+K.*DNAtot+1)-sqrt((K.*TFtot+K.*DNAtot+1).^2-4.*K.^2.*TFtot.*DNAtot))/(2.*K);
Z=TFDNA./DNAtot;
surf(X,Y,Z)
Answers (1)
Walter Roberson
on 9 Mar 2013
0 votes
in your TFDNA expression, replace TfTot by X, and K by Y.
1 Comment
rama krishna
on 15 Mar 2013
TFDNA=((Y.*X+Y*DNAtot+1)-sqrt((Y.*X+Y*DNAtot+1)^2-4*Y^2.*X*DNAtot))./(2*Y);
use '.' only where necesssary.. check always with size function. the size of X Y and Z should be same
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!