# Thread: Matlab help writting an equation

1. ## Matlab help writting an equation

I don't understand what is wrong with this equation:
Z=(n*R*y/(x-b))-((n.^2)*a)/(x.^2)

Matlab keeps telling me:
??? Error using ==> mrdivide
Matrix dimensions must agree.

Error in ==> g261x05 at 11
Z=(n*R*y/(x-b))-((n.^2)*a)/(x.^2)

when I try and run:
n=1.5; a=1.39; b=0.03913; R=0.08206
y=[273:.1:473];
x=[.3:.1:1.2];
[X,Y]=meshgrid(x,y);
Z=(n*R*y/(x-b))-((n.^2)*a)/(x.^2)
surf(X,Y,Z)
xlabel(
'Volume (L)');
ylabel(
'Temperature (K)');
zlabel(
'Pressure (atm)')

It's g285x07 in Gilat if you have the book.

Thanks

2. Originally Posted by LCuba
I don't understand what is wrong with this equation:
Z=(n*R*y/(x-b))-((n.^2)*a)/(x.^2)

Matlab keeps telling me:
??? Error using ==> mrdivide
Matrix dimensions must agree.

Error in ==> g261x05 at 11
Z=(n*R*y/(x-b))-((n.^2)*a)/(x.^2)

when I try and run:
n=1.5; a=1.39; b=0.03913; R=0.08206
y=[273:.1:473];
x=[.3:.1:1.2];
[X,Y]=meshgrid(x,y);
Z=(n*R*y/(x-b))-((n.^2)*a)/(x.^2)
surf(X,Y,Z)
xlabel(
'Volume (L)');
ylabel(
'Temperature (K)');
zlabel(
'Pressure (atm)')