# Simple Problem Giving Me Trouble

1. Dec 8, 2009

### xpack

I have this question:

http://img7.imageshack.us/img7/1399/52987960.png [Broken]

And From this I created this:
Code (Text):
delete g286x08.txt; diary g286x08.txt
clear; clc; close all; echo on
%
%Gilat 286/08
%

R=8.31;
M=0.032;
x=0:20:1000;
y=70:5:320;
[X Y]=meshgrid(x,y);

Z=4*pi*(M./(2*pi*R*Y)).^(3./2)*X.^2.*exp(-M*X.^2)/(2*R*Y);

surf(X,Y,Z)

xlabel('Molecules Speed(m/s)'); ylabel('Temperature'); zlabel('Probability')
%
echo off; diary off
And when I run it I get

Code (Text):
%
%Gilat 286/08
%
R=8.31;
M=0.032;
x=0:20:1000;
y=70:5:320;
[X Y]=meshgrid(x,y);

Z=4*pi*(M./(2*pi*R*Y)).^(3./2)*X.^2.*exp(-M*X.^2)/(2*R*Y);
Warning: Matrix is singular to working precision.
> In g286x08 at 13

surf(X,Y,Z)

xlabel('Molecules Speed(m/s)'); ylabel('Temperature'); zlabel('Probability')
%
echo off; diary off
And this image
http://img194.imageshack.us/img194/9489/30221576.jpg [Broken]

I know there should be something plotted here. Can someone help me?

Last edited by a moderator: May 4, 2017
2. Dec 8, 2009

### ApexOfDE

There is problem in this line:

Code (Text):

Z=4*pi*(M./(2*pi*R*Y)).^(3./2)*X.^2.*[B]exp(-M*X.^2)/(2*R*Y)[/B];

it should be: exp((-M * X.^2) ./ (2 * R * Y)

To avoid mistyping, i think you should disaggregate your eq. (e.g A = 2 * R * Y ; B = (M ./ (pi * A)).^(3/2);). It is easier to debug. :) That is my exp in my sim course.

3. Dec 8, 2009

### xpack

Ugh I hate when I do stupid stuff like this. Thank you very much!