8,976 reputation
1640
bio website
location
age
visits member for 2 years, 3 months
seen yesterday

1d
comment NDSolve: Couple ODE and PDE
AFAIK NDSolve can't automatically handle this, you can couple PDEs with PDEs and ODEs with ODEs but not PDEs with ODEs. But as NDSolve for all versions up to 9 uses the method by lines only for PDEs you can just as well do the method by lines by hand: generate a set of coupled ODEs by discretizaing in space and then couple that system to the single ODE. See tutorial/NDSolvePDE in the online documentation for more details, an example and even some internal helper methods which help with the discretization...
Apr
3
comment Accessing list elements by name
As you mentioned that you are relatively new to Mathematica I wonder whether you have any indication that more common ways to handle this won't do? One straightforward way is (close to Istvans answer): define your formulas e.g. as TiByN="Ti"/"N" and then insert numeric values with something like TiByN /. parameters where parameters = Thread[elements->chemistry] (you could use Dispatch for optimization). With such an approach you can very easily control whether and when to insert values. What you do looks a little like working against the (strong parts of the) system to me...
Apr
1
comment Highlighting or coloring certain words / substrings appearing in a larger string
As I think the handling of overlaps is the demanding part of your question I'd suggest to make an example with overlaps to provide a good test case for that...
Mar
30
comment Are there any cases when For[] loops are reasonable?
@TZakrevskiy: of course code readability is to a large part subjective and strongly influenced by prior experience. But there are certainly several established rules which are widely accepted and which are beyond pure personal taste. Reduced complexity seems to be a very decent and objective measure of code readability to me which was why I mentioned it in my answer.
Mar
25
comment FlipView can't handle CurrentValue[“MouseOver”]. Kernel crash
crashes when clicking on it, mma 9.0.1 on Windows 7 64bit, please report as a bug...
Mar
24
comment Permanently set options such as metric units for W|A queries
just did that. As for the default: I was guessing that as well, but have you found any documentation on that? Probably that's too much to ask for as Wolfram|Alpha certainly makes such decisions based on its AI and noone knows where they come from :-).
Mar
24
comment Permanently set options such as metric units for W|A queries
have you tried SetOptions[WolframAlpha, PodStates -> {"Show metric"}]. I can't really test as it shows stuff in metric units for me by default. Would be interesting to know what it is that determines the default...
Mar
24
comment Controlling output of graphics, the role of “;” and code structure/formatting
... instead of Print[Show[g]]; you could also use Show[g,DisplayFunction->Print]; but I don't think that is very enlightning...
Mar
24
comment Controlling output of graphics, the role of “;” and code structure/formatting
Print prints to $Output, an the usual frontend environment that will create a new output cell (actually a cell with style "Print"). Print will also work when used on the command line, there Print will really print to "stdout". DisplayFunction I consider a leftover from pre-version-6 area: The display of a graphics in a notebook then was a side effect. DisplayFunction was a possibility to do interfere with that process, e.g. suppress rendering altogether. Its main value with newer versions probably is when working without a frontend...
Mar
24
comment Controlling output of graphics, the role of “;” and code structure/formatting
I think the recommended way is to use Print[Show[...]]; per line. Unlike Print, Show has no side effects (at least not since the major changes in how graphics are handled in version 6). The magenta highlighting doesn't really indicate a syntax error, I'd rather consider it an error in the highlighting. If you find that highlighting irritating you could put the ; after the comment, add another ; after the comment or explicitly put Null after it. As documented a;b; is actually CompoundExpression[a,b,Null] ...
Mar
24
comment NDSolve in exact points - nonlinear equation (Degrees and Radians confusion)
As your interpolating functions are only valid in the t-range where you solved the equation you should include that as a constraint. I would also suggest to use NMinimize/NMaximize if you search a global min/max of a numeric function, they seem to work well for your problem:NMaximize[{zsol[t], 0 <= t <= 15}, t]
Mar
21
comment Issue with Compile
The syntax of ReplacePart (documentation for V5.2) has changed. It might be that Compile hasn't learned that change (a probable reason is that newer versions with the new syntax can use patterns which Compile couldn't support anyway). In an uncompiled evalation the old syntax still seems to work...
Mar
21
comment How can I get WhenEvent to recognize criterion I specify?
@usumdelphini: it is difficult to analyze what's going wrong without seeing the actual code. If the above suggestions don't help for your case I'd suggest to write a new question with giving more details, especially a working example will always help wonders to generate useful answers...
Mar
14
comment How to get list of duplicates when using DeleteDuplicates?
I just have noticed an upvote on this answer and guessed that was related to this question. I think the fact that a function in matlab gets the information about how many arguments its caller expects from it is very unique and somewhat unusual (are there other languages having this?). My mentioned answer did mimic that behavior by examining the stack, but it's more a hack than a solution. Without that feature, you can of course not expect a function to return different things depending on how many return values the caller expects...
Mar
10
comment Launching external program in background process with ParallelSubmit
I think you just need to DistributeDefinitions for runFijiMacro (and potentially other self-defined functions you are using within it). My guess of what happens is that the function is not known in the parallel kernels and they return the unevaluated expression. Only when these are returned to the main kernel with the WaitAll they are evaluated -- sequentially on the main kernel. Search the documentation for ParallelSubmit for DistributeDefinitions to find an example usage and some more details...
Mar
6
comment Merging two held expressions into a held compound expression
@zorank: @@ is a shortcut for Apply. @@@ is a shortcut for Apply[_,_,{1}] that is apply at first level. You'll find details in the documentation for Apply...
Mar
4
comment Why does Plot[Hold[x], {x,0,1}] work?
I would absolutely agree with your guess that it is the internal handling of evaluation control which make these work accidentially. The question remains whether that indicates that these internally do more ReleaseHolds than necessary and whether that is intended or a lack of attention. In any case it seem to not cause much problems, I think?
Mar
2
comment NDSolve with varying PrecisionGoal and WorkingPrecision
I'm not sure but I think that the difference might be that with a higher lower bound NDSolve will try to make an exact match in the x-steps for that value which might result in a slightly different discretization. You can see similar effects with e.g. NDSolve[{y'[x] == y[x] Cos[x + y[x]], y[0] == 1}, y, {x, 0, 5, 30}, WorkingPrecision -> 50, PrecisionGoal -> 50]. See e.g. this answer about the undocumented feature I used here for the x range specification...
Mar
2
comment NDSolve with varying PrecisionGoal and WorkingPrecision
I think this doesn't really do what you expect and the OP intended: if you give a start value for x=0 but ask NDSolve to solve for x=5 to x=30 in the second call it will actually solve from x=0 with high precision but only store the results from 5 to 30 in the result. If you want to only solve with low precision you should instead give the lower precision endpoint result as starting value for the second call, something like: y[0] == SetPrecision[(y /. First@low)[5], 50]...
Feb
11
comment How to make a single-variable out of a NDSolve solution?
@Sektor: I of course appreciate your politeness :-)