# Matlab help writting an equation

• Dec 11th 2009, 01:00 PM
LCuba
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
• Dec 11th 2009, 02:28 PM
CaptainBlack
Quote:

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)')

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

Thanks

./ for element by element division of the upper case variables you get from meshgrid

CB