Mathematica 9 is now available
Student Support Forum
Student Support Forum: 'problem using which' topicStudent Support Forum > General > Archives > "problem using which"

< Previous Comment | Next Comment >Help
Author Comment/Response
Nasser M. Abbasi
01/19/12 11:58pm

I could not understand what you are actually trying to do in your code.

First, you start by doing Clear["Global`*"]; then follow that by doing Which[y[t] == 0, u = 10, y[t] == 10, u = -10].

How can y[t] have any value at this point? You just did Clear["Global`*"] just before that?

You also seem to mix definitions of functions. at one point you used := and for another you used =.

These are not the same. You should use := for adj function.

I would like recommend to break your notebook into cells. Do each command in one cell, then look at the output of that command. Then go to the next command. This makes it easier for you to find an error, rather than put all the commands in one big cell and run it all as one command.

The function definitions can go in one cell, but the commands better be each in its own cell to help you find a problem.

To help debug, try each one command on its own, make sure it works. For example, call your sol[r_] function as a stand along, to make sure it does what you want. Do the same for adj[], before putting everything together.

Will look more into your code when I have more time.

URL: ,

Thread 'problem using which' is now CLOSED
Author Date Posted
problem using which lina 01/19/12 07:43am
Re: problem using which Nasser M. Ab... 01/19/12 11:58pm
Re: problem using which Nasser M. Ab... 01/20/12 00:14am
< Previous Comment | Next Comment >Help