Simple Problem Giving Me Trouble

  • Thread starter xpack
  • Start date
In summary, the conversation is about a problem with a code that is supposed to plot a surface graph. The problem is identified as an error in one line of the code, which has been corrected. The conversation also suggests disaggregating equations to make debugging easier.
  • #1
xpack
37
0
I have this question:

http://img7.imageshack.us/img7/1399/52987960.png

And From this I created this:
Code:
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:
%
%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

I know there should be something plotted here. Can someone help me?
 
Last edited by a moderator:
Physics news on Phys.org
  • #2
There is problem in this line:

Code:
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
Ugh I hate when I do stupid stuff like this. Thank you very much!
 

1. What is a simple problem?

A simple problem is a task or issue that is relatively easy to understand and solve. It typically does not require extensive knowledge or skills to find a solution.

2. Why is a simple problem giving me trouble?

There can be several reasons why a simple problem is giving you trouble. It could be due to a lack of understanding or knowledge in the subject matter, not having the right tools or resources to solve it, or being overwhelmed by other factors that are affecting your ability to focus on the problem.

3. How can I approach a simple problem that is giving me trouble?

One way to approach a simple problem is to break it down into smaller, more manageable parts. This will help you to better understand the problem and identify any areas where you may need more information or assistance. You can also try asking for help from a friend, colleague, or expert in the field.

4. What are some common mistakes people make when trying to solve simple problems?

Some common mistakes people make when trying to solve simple problems include overcomplicating the issue, not seeking help when needed, and not taking the time to fully understand the problem. It is also important to avoid rushing to find a solution without fully considering all possible options.

5. How can I improve my problem-solving skills for simple problems?

To improve your problem-solving skills for simple problems, you can practice by regularly engaging in activities or tasks that require critical thinking and logical reasoning. Additionally, seeking feedback from others and learning from your mistakes can also help to enhance your problem-solving abilities.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Calculus and Beyond Homework Help
Replies
3
Views
546
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Introductory Physics Homework Help
Replies
1
Views
983
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
2K
Back
Top