« first day (470 days earlier)      last day (4011 days later) » 

12:45 AM
Extract will do the job.
 
@soandos. If m is your matrix, then m[[All, 1 ;; 3 ;; 2]] should do it.
 
 
1 hour later…
1:59 AM
@m_goldberg thanks
 
 
5 hours later…
6:46 AM
0
Q: Interested in authoring a book on Mathematica for Packt?

Mohammad RizviMy name is Mohammad Rizvi, I am an Author Relationship Executive at Packt Publishing. We specialize in publishing IT related books, e-books, and articles that have been written by experts in the field. Packt is planning to publish a book on Mathematica, titled Mathematica Data Visualization . ...

 
 
8 hours later…
2:49 PM
Hello everyone.
 
Hao
 
3:00 PM
Welcome @Ghersic :-)
I see you were ten minutes early.
 
@Mr.Wizard What's up, long time
 
Yes haha, a little eager.
 
Hello @Rojo :-)
 
You're on a date?
 
@Rojo heh, I'm walking @Ghersic through some basics to help him get started.
We had code like this:
AP6156z = Take[AP6156, 4 ;; 4];
AP6157z = Take[AP6157, 4 ;; 4];
AP6158z = Take[AP6158, 4 ;; 4];
AP6159z = Take[AP6159, 4 ;; 4];
AP6160z = Take[AP6160, 4 ;; 4];
AP6161z = Take[AP6161, 4 ;; 4];
AP6162z = Take[AP6162, 4 ;; 4];
AP6162z = Take[AP6162, 4 ;; 4];
AP6163z = Take[AP6163, 4 ;; 4];
AP6164z = Take[AP6164, 4 ;; 4];
AP6165z = Take[AP6165, 4 ;; 4];
AP6166z = Take[AP6166, 4 ;; 4];
AP6167z = Take[AP6167, 4 ;; 4];
That's no way to enjoy Mathematica. :^)
 
3:03 PM
Yes, I am very new. Mr. W is nice enough to show me quality over quantity coding.
haha very true
 
Hehe
Glad it's you and not Leonid
 
@Rojo Why's that?
 
He would be teaching how to make a macro to create a macro generating package generator that automates the decision of how to remove the boilerplate code
That's for tomorrow's class :)
 
Phew, I am too, then! haha
 
LOL -- well, it'd be a well oiled machine when he got done, but probably a bit much to learn in the first week. I'm having a hard enough time as it is not hitting the new guy with every concept in the quiver.
@Ghersic okay, so yesterday we had the recordToRule function written. I'm going to make a modification to that now to conform to a personal "style" principle. We had your time values hard-coded, i.e. Transpose[{{5, 10, 20, 1440}, {data}}] such that you would need to change the definition itself to change these values.
We could make this rely on the global value of the symbol time instead, but I (and others) tend to think that is poor style as it's too easy to create hard to trace bugs.
 
3:09 PM
Ok, that seems useful. Yes I've ran into small definitions problems... they do seem like the last thing you think are creating the problem.
 
Instead, I think this list should be passed as a parameter of the recordToRule function. There are a couple of ways to do that. My preferred way is to use the syntax recordToRule[timelist][record]. This can be effected either by writing the function such that recordToRule[timelist] produces a new function which is then applied to record, or by making a "SubValues" pattern definition directly.
As a sidebar, the first method would work because "heads" are evaluated first in Mathematica. For example, the expression f[x][y] (remember, everything is an expression tree) has the "head" f[x].
You can see this with:
Head[f[x][y]]
 
@belisarius I wouldn't either
 
f[x] therefore is evaluated first, and it can evaluate to a new function, which then takes the argument y.
 
@Rojo They are broadening their net
-2
Q: Interested in authoring a book on Mathematica for Packt?

Mohammad RizviMy name is Mohammad Rizvi, I am an Author Relationship Executive at Packt Publishing. We specialize in publishing IT related books, e-books, and articles that have been written by experts in the field. Packt is planning to publish a book on Mathematica, titled Mathematica Data Visualization. W...

 
@Ghersic In addition to the help documents you may wish to bookmark this.
 
3:15 PM
Ok. I remember TreeForm to generate the expression tree you're talking about, and it makes sense that f[x] be processed before [y]. I'll certainly read your answer on function form / manipulation.
 
The second method is to make a definition such as f[a_][b_] := stuff, which Mathematica understands. There are limitations to this format, as the argument b cannot be held unevaluated for example, but often this is quite convenient.
Also to bookmark here is an answer of mine where I describe both of these methods.
 
Ok, that method sounds similar to a different answer to my question you answered. Ah excellent, thank you! I'm sorry to make you reiterate yourself too much, then.
 
Not a problem, I volunteered to help.
 
:)
 
Let us now write our code as:
time = {5, 10, 20, 1440};
recordToRule[time_List][{name_String, data__}] := name -> Transpose[{time, {data}}]
ruleData = recordToRule[time] /@ Part[data, 2 ;;, 1 ;; 5];
Here there is not a lot of benefit seen from the new syntax, but should you need to change time you can see that it would be convenient to do so.
 
3:19 PM
yes
 
Okay, another sidebar before I address plotting. The z and P code lines, e.g. AP6161z = Take[AP6161, 4 ;; 4]; can be written much better of course.
 
Cool.
 
You are using Take, followed by Flatten, to do what could be done with Part (which has the expr[[index]] syntax) directly.
We have somewhat complicated this with our Rule-based data format, as the data itself is now in the second part of the rule. For example, the rule x -> {1, 2} has Head Rule, part one x and part two {1, 2}. Understood?
 
Ah ok, funny, I even use Part earlier in my code.
Yes
 
Trust me, it takes a long time to use every function most efficiently. I've been at this for years and I'm still learning. J. M. has been at nearly from the beginning (some 20 years I believe) and I think he'd agree with that too.
 
3:26 PM
Haha, that makes me feel a little better.
 
You will however find that it doesn't take a lot of time to begin writing much more usable code, and you shouldn't spend too long hunting perfection when you can hammer out something that works. The idea it to spend the least human-time required to get the job done; something Mathematica is very good for IMHO.
 
That's great. I had heard that before and was wondering what on earth I was doing wrong.
 
Okay, a sidebar to a sidebar (sorry, I'm not well organized about this). Let me back up and mention that there are usually a number of different ways to do the same job, and there can be different strengths and weaknesses to each.
 
No problem, that's what permalink is for, as you mentioned!
 
In time you will find that there are strong differences in the performance of different styles of code. In recent versions, and for those so inclined, there is the ability to compile code to C and get very high performance, but you will find yourself writing longer, procedural-style code to do so. I don't do much of that so you will need to talk to someone else if you are interested. At a higher level there are also different styles that tend to produce different performance outcomes.
 
3:32 PM
@Mr.Wizard Leonid and Oleksandr are the kings of Compile I think, right?
 
I'm also not going to get into that too much other than to make one small point: pattern-based operations are typically not going to be as fast as operations done by part index, and numeric operations (such as the Listable array + 5 example) are even faster.
 
Ok. C would be a new concept to me, so it is probably best I stick with the "doing what works" motif in-house.
 
I am choosing to show you a number of pattern-based definitions because I think they are the most human-usable and easily customized.
 
Indexing does seem very efficient.
Ok, that's alright. They seem very usable and a good start.
 
@Rojo I'm not really qualified to judge but they both seem knowledgeable! :-)
I'll take this z/p operation as a change to show you an example of each so you can see what I mean.
We can write:
pfunc1 = #[[2, 4]] &;
 
3:34 PM
@Mr.Wizard You are the king of this forum, the Zeus, you're the only one qualified to judge other kings
 
I'm turning rojo here. :-o
 
Haha
 
lol
 
You can now try: pfunc1 /@ ruleData which should produce:
{{1440, 66.8786}, {1440, 96.6977}, {1440, 37.382}, {1440, 99.0795}, {1440, 52.0696}, . . .}
You don't even need this function to be named, as you could use ruleData[[All, 2, 4]] which would actually be even more efficient. Nevertheless you may find yourself having to remember what 2 and 4 represent, etc.
be right back -- email
 
Ok yes, it does produce that. I'm guessing the {2,4} represents positions in ruleData, then? No rush, of course. :)
 
3:40 PM
It was nothing. Yes, All, 2, 4 is the index of the element we wish to extract in the ruleData expression tree. That is, All parts at level one, part 2 of each of those, and part 4 of each of those.
Again, when it is possible/reasonable to operate by parts this will typically be very fast. Another approach would look like this:
pfunc2[name_ -> {_, _, _, four_}] := four
We now have a pattern that destructures one of our records, and it's quite literal to see what it does once you are familiar with pattern matching and replacement.
 
Ok, I remember your link to restructuring from yesterday as well.
destructuring, that is.
 
You'll notice the named pattern name_ is not used on the right-hand side; here it merely serves as a label. However be aware that any pattern with the same name (label) must have identical contents or the entire pattern will not match. For example, {a_, a_, other__} will match {3, 3, 4, 5, 6} but not {1, 2, 3, 4}.
Let's move on to the thirds function from my answer to your question. Do you understand it?
For reference:
thirds[lst_List] := Partition[lst, #, #, 1, {}] & @ Ceiling[Length@lst / 3]
 
I think so. Here the _ without any text attached is referring to name as a label only?
 
@Ghersic Pardon me, what are you referring to?
(Pardon me, I'm tossing out too much at once again.)
 
Oh nevermind, sorry. I missed the name_ on the left hand side of our pfunc2 definition. Nevermind.
 
3:49 PM
@Ghersic Let's back up to that one. You see that the pattern name_ -> {_, _, _, four_} is analogous to our record data format, correct?
 
yes
 
There are five patterns and two literal expressions. The literals are Rule (->) and List ({}). Each _ (full name Blank) is a pattern. Two of the patterns are named (name, four), three are not.
Shall I move on to dissecting thirds or do you have any questions?
 
Sure, thank you. No I think that cleared them up well.
 
First things first, let's make sure that you have the tools needed to break down and begin to understand code that you come across. You can highlight (select) function names or operators, and press the F1 key to bring up the documentation page for that object. Try it now on Partition and on #. (You don't have to have the word selected; it is sufficient to have the cursor somewhere inside the word; try it both ways.)
This is all inside the Front End of course, which I assume you're using.
 
Oh wow, that does work wonders. Yes I am using the front end.
 
3:57 PM
Great. :-) Okay, the second tool(s) for breaking down expressions I described here. Please take a minute to skim that, then bookmark it for reference.
 
Okay
 
Particularly I would suggest you start using the Ctrl+. functionality immediately; it is very helpful IMHO, as Mathematica has a complex hierarchy of precedence.
Alright, back to thirds.
thirds[lst_List] := Partition[lst, #, #, 1, {}] & @ Ceiling[Length@lst / 3]
Hello @Oleksandr
The thirds function is a SetDelayed definition with a single parameter, named lst. It must have head List thanks to the pattern _List.
 
@Szabolcs @rm-rf congratulations on your release of MATLink! I'm not a MATLAB user, but it almost makes me want to try it. :) I was impressed with your attention to the website as well--that will surely help attract users.
@Mr.Wizard hello!
 
The function is composed of a subfunction also with a single parameters; this is done to simplify the code and remove repetition.
 
kk
 
4:03 PM
I should mention now that I often use a somewhat uncommon syntax for function application: f @ x which is equivalent to f[x]. I use it because I find that code with a lot of nested brackets gets very hard to read.
 
@belisarius this question has been closed now but I did my own search and found that negative views of Packt seem to be in the minority and arise mainly due to their habit of spamming people in order to recruit authors and reviewers. Real experiences doing these things seem to be better: reviewer, author. So I would suggest that people keep an open mind.
 
Ok, noted.
 
So we pass Ceiling[Length@lst / 3], which is simply the length of a third of the lst rounded up to the nearest integer, to the function Partition[lst, #, #, 1, {}] &
 
@OleksandrR. OK, understood ... but I don't like to be spammed
 
You can refer to the documentation for Partition (which has a fairly elaborate syntax) to see how this works, but for now it's simply enough to say that this splits the list into non-overlapping sections of the given length, and allows the final section to be shorter of needed.
 
4:07 PM
Ok.
 
I think we're finally ready to start talking about plotting, but be warned that once again I'm going to hit you with a bunch of stuff you'll need to read about on your own.
 
@belisarius your response to that is quite understandable and mine would be the same. I just wanted to note that despite the discouraging start this publisher actually does not seem to be entirely disreputable.
 
Excellent. I do have a lab meeting that I sort of committed to attending, is there any way I could log in tomorrow or later this evening at any time convenient for you? I'm very excited to discuss plotting in the new, more elegant context we have now.
 
I thought we had fifteen minutes? No matter, we can pick it up another time. I cannot commit to a specific time tomorrow but I can try.
 
That is, that starts in about twenty minutes and should last about an hour and a half. I'm so sorry for the interruption, I wouldn't have volunteered to have gone if I knew we would be discussing Mathematica stuff now.
we do have about ten minutes still. again, so sorry for the interruption.
 
4:11 PM
lol -- no problem.
 
lol honestly I would rather talk about this with you. I'll remain online tomorrow throughout the day and will thoroughly review the links you've sent in the meantime.
If you'd like to start on graphing though and think we can make progress in 10-15m I would love to though. I just wanted to let you know before t = 0!
 
For now I'll just reference a couple of posts. Both are pretty advanced (for different reasons); don't drive yourself crazy trying to understand them, just absorb what you can and later, in time, certain ideas should start falling into place. In this post I describe in detail how to write a customized Grid function, and the same methods can be applied to a plotting function.
This question, and its several answers, should become important if you intend to label these lines in the way I think that you wish to:
 
Ok, excellent.
 
20
Q: Labeling individual curves in Mathematica

xiongtxI need to create a plot for export and inclusion in a report. Is there a better way to label curves than PlotLegends? From what I've read and my personal experience, PlotLegends is pretty bad. Is there a better package for legends, or, ideally, a simply way to place small text next to each curve?

 
Awesome! Legending has been haunting the back of my mind.
 
4:15 PM
I will use the method from the Accepted answer in my examples (tomorrow) but know that we're getting into some fairly complicated replacement rules if you are going to try to understand that right now.
@Ghersic Mathematica 9 introduced improved legend functionality, which as a version 7 user I do not have. To that end it will be better for someone else to instruct you in that area once it is needed.
 
Ok, I will be doing alot of reading tonight and tomorrow in preparation for that.
 
Let me think of there is anything else I can reference for you before we adjourn.
 
Alright. I have used some of v9's legending features and think that one way or another it will be easy to figure out. So far (for what it's worth) I've tended towards making my own legend rather than using v9's new features. Perhaps the article you linked will help me in that.
Ok.
 
No, I think that's enough for now. I suggest you spend any extra time you have learning to use the documentation. In addition to the direct F1 look-ups make sure you are aware of the Virtual Book under the Help menu, and it is a more linear tutorial for nearly all the workings of the software.
 
Ok, I'll be sure to check that out. Thank you again, Mr. W!
 
4:20 PM
Again, no promises but I'll try to be on-line around 1500UTC again tomorrow.
 
@belisarius Seen this? mathematica.stackexchange.com/…
Look at our score ;-)
 
Sounds good. Thank you. I'll be on throughout the day if another time is better instead. Thank you again.
 
@halirutan Hehe,
I'm ahead
 
@Ghersic You're welcome. I hope the meeting goes well.
 
@halirutan We have our methods :)
 
4:22 PM
@belisarius yes, and I don't know why. Maybe you made the more heroic answers ;-)
 
Thanks, bye everyone.
 
@halirutan The sorting routine executes from time to time :)
 
4:51 PM
@OleksandrR. I too researched and found that they were a decent company, but the closure here has nothing to do with the quality of their service. They are known to spam "experts" and nag them about writing a book and this is not something that we want to encourage here (also, they hit belisarius a few days ago, and possibly others with a visible email address/website)
but if there's an interest in the publisher, I can ask someone who has published a book with them to provide a first hand account of how the experience was...
 
@OleksandrR. The website is all rm's work
 
5:10 PM
@rm-rf I understand and agree with the reason for closure. Because of the negative account of the company given by cormullion I was going to put in a counterbalancing comment, but then it was closed so I put that here instead. Even if the question is not appropriate for our site, I wouldn't want to have people discouraged people from writing books on Mma if they want to do so.
 
I found an error in the DSolve of mathematica :D
 
@OleksandrR. Please add a comment there as well, if you feel that the comments paint an overly negative and unfair picture of the publisher. My comment and close vote was more on the OTness, because it seemed like there was an effort to legitimize such questions on a trial basis (mainly because not everyone knows that such offers/job spam is not uncommon, and the reason no one sees such posts is because we nuke it quickly)
 
@rm-rf I can't comment any more, precisely because it's closed. This seems a special aspect of Meta.
 
@OleksandrR. What?
ahhh... no. I'll fix this. brb
@OleksandrR. You should be able to comment now
 
@rm-rf thanks, yes it works now
What was the problem there?
 
5:26 PM
@OleksandrR. When a question is migrated from A -> B and then gets closed on B as anything other than a duplicate, it is locked on B and unlocked (and "unmigrated") on A. This is to prevent two "live" copies of the same question floating around on different sites. I just had to unlock it on meta (B)
 
@rm-rf I see. Makes sense in most cases, I suppose. I added the comment now.
 
@halirutan How do I prompt IntelliJ to bring up the help for a symbol?
 
@Szabolcs In OSX?
@Szabolcs Btw, good new. It seems I have permission from Wolfram.
 
@halirutan Yes
@halirutan Great!
 
In OSX I think it's Ctrl+j
 
5:40 PM
If you have a newer version of the plugin, please send it. I'm using it right now.
 
I found and ode which i can solve but mathematica can't :D
 
@halirutan excellent! Did they take much persuading?
 
@halirutan You can look it up under Help->Reference Sheet
@OleksandrR. Leonid did a great job. I just have to use a copyright fileheader in the help files saying that this was extracted from Mathematica
 
@halirutan well, that's easy! Do you think this approach can be generalized to other cases where we might like to build some program that interoperates with Mma and needs to contain information on some of its functions?
 
@OleksandrR. I don't know. I hate legal stuff but when you send me a mail, I describe the details of Wolframs conditions.
 
5:49 PM
@halirutan it's okay, I don't have it in mind to build any such program at the moment so I won't bother you with this for now. :)
 
@halirutan I'm not even on the first page :/
 
@Rojo It seems you succeed better than me to not waste so much time here and doing something useful instead ;-)
 
@Szabolcs sometimes it amazes me how much more willing people are to write a question on SO rather than attempt to engage the brain
 
@halirutan The second part of that statement isn't entirely correct :P
 
@Rojo hehe that was what I was hoping for. Now I don't feel so bad anymore ;-)
 
6:03 PM
@halirutan I'm glad :)
If I wanted you to feel bad I would have reminded you of your camel humps
 
@Rojo Hehe and I could send you a screencast of the idea plugin where this is working now :)
 
@halirutan Interesting....
 
@halirutan You could send it as a feature suggestion to wri though
 
6:20 PM
@Szabolcs Check that "yet"
 
I'd take that as "not completely dismissed". I think that for a feature to be implemented it's not enough for one of the leading devs to support it. They'd need to argue that the feature would see actual use and that there's demand for it. Feature suggestions sent to support matter here.
At least that's my guess.
@OleksandrR. The intersection of "points" thing? Yes, that was pretty bad.
 
 
5 hours later…
hhh
11:52 PM
I am trying to add the image as a texture to the cylinder, what else do I need to specify? I cannot understand why it is not firing any errors.
 

« first day (470 days earlier)      last day (4011 days later) »