« first day (509 days earlier)      last day (2703 days later) » 

12:06 AM
> If you specify nonscalar arrays, MATLAB interprets j:i:k as j(1):i(1):k(1).
 
colon, somehow we always end up there
 
The source (or it is sink?) of all fun
 
;)
 
12:33 AM
@AndrasDeak Quick Python question: I was trying to understand this answer. Why does max([(3, 0), (2, 1), (6, 2), (5,3)]) return (6,2)? Does max use lexicographical order as I assume sort does?
Also, why does max([(3, 0), (2, 1), (6, 2), (5,3), (6,2,-10)]) give (6,2,-10)?
 
lemme see
I've never seen native python max acting on a list of tuples before:)
but yes, it indeed seems lexicographical
 
Does sort use lexicographical? It would make sense then that max does too
 
it seems to, yes
In [64]: sorted([(3, 0), (2, 1), (6, 2), (5,3), (6,2,-10)])
Out[64]: [(2, 1), (3, 0), (5, 3), (6, 2), (6, 2, -10)]
 
Yes, sorted gives consistent results with max
 
I can't really say why the longest tuple is found when there's a tie...
 
12:36 AM
Ninja'd
 
I don't have experience with this, sorry:)
 
@AndrasDeak No, it's clear to me now, thanks!
 
I'm glad:D
 
 
9 hours later…
9:29 AM
Interestingly, imresize works for 3D images somtimes
no, in fact it always ignores the 3rd dimensions
damn
 
9:55 AM
@AndrasDeak On second thought, that's part of the definition of "lexicographical" (as in word dictionaries): longer comes later when existing letters give a tie. So it makes sense
 
I use that words in my paper to sound smart
:P
not really, it helps describe the order very nicely in a single words
but sounds smart
 
 
2 hours later…
11:35 AM
@LuisMendo oh, right, I missed that:)
 
12:34 PM
@LuisMendo Sorry about that, I was driving all day yesterday. I rebooted. The issue is so strange. Basically for some jobs if Octave has to be force-quit then the next time you boot up octave it just hangs. I thought before that it was trying to restore it's previous state or something but that didn't pan out. I'll have to try to create a script which recreates the issue and see if maybe there are some additional input arguments that will prevent that from happening
 
@AnderBiguri smart word and with a Greek origin, so even better :-D
@Suever Not sure if Octave is to blame, but it always seem to be in the middle of strange issues :-D
 
12:49 PM
It pains me to admit this is clever
1
A: How to read 3x3xN coordinates string into matlab array efficently

rahnema1You can use eval function: str = '[1,2,3.14],[4,5.66,7.8],[0,0,0],'; result=permute(reshape(eval(['[' ,str, ']']),3,3,[]),[2 1 3]) result = 1.00000 2.00000 3.14000 4.00000 5.66000 7.80000 0.00000 0.00000 0.00000 Using eval all elements concatenated to create a row vector. Then ...

 
1:00 PM
and it's faster than sscanf :|
 
str2num is fine
not as fine as something better, but at least it won't erase your hard drive
 
@excaza I did not know str2num run eval
thats terrible
 
Nov 23 '15 at 11:00, by Dev-iL
>**Note** str2num uses the eval function to convert the input argument. Side effects can occur if the string contains calls to functions. Using str2double can avoid some of these side effects.
I clearly didn't remember that detail ^
if I had free memory to fire up matlab, I'd try str2numming a disp()
 
@AndrasDeak are you chatting in a raspberry pi ?:P
 
hmm actually, there's 44% chache that my system monitor shows as allocated, for some reason
but matlab's a memory hogging poo, that's partly why I started moving to python
 
1:15 PM
yup it is
 
OUCH
>> str2num('[system(''touch ~/TMPFILE_GOTCHA'')]')

ans =

     0
2
$ ls ~/TMPFILE*
/home/user/TMPFILE_GOTCHA
 
lol
 
now that sucks
count me in the "str2num is evil" group
 
That's strange, because I can see ways of making a str2num without eval
and MATLAB themselves say that eval is bad
 
1. not versatile enough or 2. too much work
I think it's made like that so that str2num(['[1, 2, rand(1,2)]']) works
OK, gotta go bake some cake
 
1:28 PM
I'm just going to go back to my coffee :p
 
1:45 PM
-1
Q: Sum of multiples of 3 and 5 MATLAB

m.aIf we list all the natural numbers up to 10 that are multiples of 3 or 5, we get 3, 5, 6, 9 and 10. The sum of these multiples is 33. Write a function called sum3and5muls that returns the sum of all the unique multiples of 3 or 5 up to n, where n is a positive integer and the only input argumen...

it's actually working correctly though...
It's just a union, and it's correct
 
0
Q: Matlab: Defining a hardcoded matlab code dynamically? How can i do this in order of my code?

MuellerIs there the possibility to create my diagram options(i), diagramlimits(i) and inputdata(i) dynamically with a for loop - or with another way -> i=3? I don't want to write it hard coded like in my code at the moment. At the moment a big part of my code is repeating. Only the variable names are c...

eval ^
 
" The presence of eval is a very good sign" ?
 
too late to edit!
 
2:08 PM
@AndrasDeak Heh. Yes, the fact that str2num is eval in disguise is not sufficiently well known
@AnderBiguri They have str2double for that. But annoyingly, it only handles scalars. Is it so hard to do an eval-less vectorized string-to-number conversion?
 
I use str2num all the time
I should maybe stop
 
Maybe... :-D
Another possibility is to check (via regexp) that the string doesn't have any harmful content
 
fortunatedly for me I use str2num to covner to string for loop indexes and so on
so nothing bad will happen and I dont need to sanitize intputs
 
:-D
 
We should edit that to say eval('Robert;system( rm -rf/)')
 
2:14 PM
Yes, I sometimes use str2num when I'm pretty sure that only I will use the code. Even input uses eval in disguise :-(
 
I think the str2num case is far more dangerous than pure eval, tbh
 
yes it is
because its hidden!
 
Exactly
Same with input. No one really stops to think what happens if the user enters a certain string instead of the required "integer number"
>> x = input('Input a number: ')
Input a number: system('dir')
 El volumen de la unidad C es Windows
 El número de serie del volumen es: 229E-1757

 Directorio de C:\Users\Luis\Desktop

21/11/2016  13:49    <DIR>          .
21/11/2016  13:49    <DIR>          ..
15/07/2016  08:41         1.196.631 06824752.pdf
[...]
 
que lastima!
 
:-D ¡Sí!
Or do you mean lástima that I use Windows? :-)
 
2:21 PM
no, I use windows pretty much everywhere
I'm not dedicated enough to use linux
-1
Q: From vpi to double

John988How can I convert from vpi to double. `for example: bin2vpi('101010101111100011101010101111100011101010101111100011101010101111100011101010101111100011101010101111100011101010101111100011101010101111100011')

this is like pulling teeth
 
@excaza Same as here. I like Linux, specially the fact that you can get into the system, and lear, much more than with Windows. But Windows is just easier for me
 
its this one
but yeah, I decided not to help there
@LuisMendo this is so terrible
VERY terrible
 
2:52 PM
" hough_circle function, but i doesn't work" Does it make your computer explode in millions of colorful pieces? Why does not work? Please, read How to Ask and Minimal, Complete, and Verifiable exampleAnder Biguri 29 secs ago
That "colorful" made me chuckle :-)
 
Argh, sorry, I meant "the presence of eval is a very good sign that you're doing something wrong". What I would do is to switch from var1,var2,var3 to either a cell with var{1},var{2},var{3} containing what you have now, or a struct with something like var.f1,var.f2,var.f3 etc. But in the struct case, you can even drop the numbers, and use meaningful field names, if that makes sense. The huge difference between your original and the struct one is that in the latter case you can use fname='f1'; var.(fname)=... to dynamically (and safely) assign to a field of the struct. — Andras Deak 13 secs ago
 
@LuisMendo I try to very my possible why does nto work
velocirraptors were involved in some cases, If I am not wrong
 
:D
@excaza love it
 
@AnderBiguri Heh. xkcd again, right?
 
everything is xkcd
What happens here?
1
Q: Matlab code would not plot part of the function

thephysicsguyI tried recently to plot some velocicty fields for a tutorial problem in my fluids problem set. I wrote the following Matlab code clear; h_theta_multiple=0.01; h_theta=h_theta_multiple*2*pi; h_rho=0.1; [theta,rho] = meshgrid(0:h_theta:2*pi,0:h_rho:5); [x1,x2] = pol2cart(theta,rho); N=[1 2 3...

 
3:10 PM
u1 and ù2` contain inf. quiver probably auto-scales
 
@AndrasDeak Are you laughing because by variable name looks a little like Hungarian text? :-P
 
just a little, we have ú, all our accents are acute;)
but yes:D
 
@LuisMendo if I give scale values, it sitll does not show
 
@AnderBiguri But I think that scale is for the arrow length, not for the underlying values
 
3:18 PM
ah!
that can be yes
 
@LuisMendo Python is all too powerful... to find whether a substring is found in a string...
>> s = 'luis'
>> st = 'luismendo'
>> s in st
True
I was expecting some fancy function like strfind or something... in lol.
but of course I still love MATLAB.
 
3:35 PM
@rayryeng It is! I'm barely scratching he surface though
 
@rayryeng yup:P
half the time if you write pseudocode, it will almost run in the interpreter:D
are you familiar with operator chaining?
1 < x <= y < 3 will do what you expect it to
 
user image
4
@AnderBiguri ^ Next time maybe use this
 
haha:D
 
LOL
The beard also fits....
Am I an alcoholic? I hope not
 
@AnderBiguri I hadn't thought of the beard, but yes, that too! The funnily-annoyed tone in the comment reminded me of Captain Haddock :-)
 
3:41 PM
hahaha
 
@rayryeng What was the IDE you use, iPython? I had IDLE (which seems to be the default, smallest one), but it was difficult to install packages. Scipy complained that it didn't find a BLAS export or something. So I installed Anaconda, which seems to be a complete distribution with everything included. I use its Spyder interface, which makes me feel at home (read: it is Matlab-like)
 
@LuisMendo Spyder is cool!
I really really like Ipython notebooks or Jupyter nowadays
it helps you make nice reports with the runnable code!
 
@AnderBiguri One thing bothers me, though. When I set dark theme (background) the interpreter is dark but the other panels (variable explorer etc) are white
 
@LuisMendo as when you try to do that in MATLAB.....
 
Can't they be made dark too?
@AnderBiguri Oh, really? Never tried in Matlab
 
@AnderBiguri All that was made with Ipython? Wow
 
Its not made in Ipython
that is an Ipython notebook
 
Can those In [1]: be removed in the interperter?
 
I think that is so you know the order of execution
but it has export to tex option
 
@AnderBiguri and they are actual variables
 
3:48 PM
and generates .tex files
 
you can access Out[1] later
same logic as that of Mathematica
 
@AnderBiguri Yes, I agree they can be useful. But I find those numbers distracting
 
Did not know that!
 
@AndrasDeak Oh, how does that work?
 
In [354]: print(In[353])
plt.figure(3,figsize=figsize)
 
3:49 PM
So In is a list of what?
 
In [356]: np.random.rand(3)
Out[356]: array([ 0.37927332,  0.04415803,  0.27315503])

In [357]: Out[356]*2
Out[357]: array([ 0.75854663,  0.08831607,  0.54631005])
@LuisMendo a dict?
maybe a list
In [358]: type(Out)
Out[358]: dict
(in python, everything is a dict)
 
wat
 
@AndrasDeak Yes I'm familiar. I don't use it often though as I like to be explicit.
 
(when you go below the surface)
 
a dict or a list
 
3:51 PM
gotta go now, we can keep pythoning after;)
 
@LuisMendo I actually don't use an IDE. I use VIM + IPython
However, a great IDE is to use PyCharm.
 
or Visual Studio Code
 
@AndrasDeak I'll have to experiment with that :-)
 
Also Spyder is a great thing from Anaconda. That's also what I recommend
 
@rayryeng So many IDE / interpreters / whatever for Python!
 
3:51 PM
@excaza Yes, I forget about VS Code
That was recent and it's really good.
 
@rayryeng I like that one. Very Matlab-like
 
I agree :) Divakar uses it often as well
 
I like PyCharm but I find it too feature-rich, I get that it's aimed more towards an Eclipse/VS like environment but it's filled with stuff I don't ever need to use
and kinda slow
 
@excaza I agree. If I were to choose, it'd be Spyder
however I'm a purist and use IPython + a text editor.
Vim, Atom, etc.
I do need to give VS a try thoguh. I've seen the features and they're fantastic.
 
Atom <3 , vim-> ITS 2016 WHY IS NOT DEAD
 
3:55 PM
I've really only used it for making Windows C++ applications.
@AnderBiguri because the shortcuts and the way to write code is VERY Fast.
it's optimized for using just keyboard.
 
yeah....... but it breaks brains
 
lol.
 
@rayryeng Now I remember that's the one you recommended to me :-)
Sep 14 '15 at 22:44, by rayryeng
Also, the easiest way to get Python installed is to use the Anaconda Package from Continuum Analytics.
 
CTRL+T+S+A+G+W+D for selecting words that start in "a"
 
If you like Atom then you'll like VS Code
 
3:56 PM
@LuisMendo oh yeah :D
 
they're both built in electron and function similarly
 
Back in the day, moving your hand off to move the mouse can waste a bit of time
if you never take your hands off the keyboard, you save some cycles :P
@excaza ok I'll give it a try
 
I would guess that VS Code will mature faster than Atom
 
yup makes sense. more support
 
since MS is developing it, I found Atom pretty lacking (and slow) last time I used it about a year ago
though a lot of that could be artifacts of our IT rules
 
4:30 PM
@rayryeng They're working on VS for Mac. I do need to try Atom though.
 
4:54 PM
anyone heard from @ballBreaker lately? How's the little lobster doing without a job?
 
@Adriaan He got an offer from a company I referred him to last Thursday
that's why his last day was on Thursday.
 
\o/ that's fantastic to hear
no more whining lobsters in here :P
 
He's now deciding how much time he wants to take off before starting his new job
nope lol
but he's safe. He has a new job. I've referred at least 5 opportunities to him. I'm glad he got one.
 
jolly good to hear
 
@beaker Atom is nice. I'm still getting used to it but it's designed very nicely... you don't even need to use your mouse.
 
4:57 PM
did they add support for opening files > 2 megs yet?
 
5:14 PM
what a stupid list
fuck, I have a flight next week, better get myself a $550 scarf
or a $970 suitcase
 
@excaza sooo, why did you share it? :P
 
for others to revel in the dumb
 
I Assume that thign is a bit sarcastic
 
5:34 PM
The fact that it came from Wired is sad. I figured they would be above this narcissistic bullshit.
 
> and it comes in rose gold (flashy!)
yeah, um, no.
 
5:58 PM
[This](http://stackoverflow.com/questions/40685307/detect-circle-using-matlab)
and [this](http://stackoverflow.com/questions/40723326/draw-line-and-cut-off-circuler-area) probably need to be hammered as duplicates of each other
 
6:13 PM
@AnderBiguri no, that's emacs
vim is wonderful after the 12 hours you need to get started with it
 
I had the feeling that VIM is similar the very little I used it
yeah....
I used it a bit for git, to write my commits. EVERY TIME I needde to relearn how to quit
every time
 
6:25 PM
they're very different
 
I guess they are :P
I am still not convinced to use any of them
 
that's OK, you're always entitled to your wrong opinion
 
@Luis one more thing: in the interactive python shell the last printed return value is stored as _
>>> [k**2 for k in range(5)]
[0, 1, 4, 9, 16]
>>> tmpvar = _
>>> print(tmpvar)
[0, 1, 4, 9, 16]
although I just use ipython for any interactive business
 
7:13 PM
@AndrasDeak Yes, I knew that, thanks! Very useful. Faster to type than ans :-)
 
It looks like Skeptiks.SE likes maths

https://skeptics.stackexchange.com/questions/35991/do-american-foods-contain-unsafe-levels-of-glyphosate/35993#comment137389_35993
 
7:30 PM
1
Q: Octave: Function fails, while Script runs

niakNote: This question has three flaws, which I realize: I have not found a simple way to reliably reproduce the error. I don't know the source of the problem and hence also not the correct keywords. Since I only have Octave at my disposal, I cannot say, if this could also happen in Matlab. I st...

-.-
> Therefore the script most likely is NOT the problem, but just happens to be the procedure by which I found the problem.
I mean, it most likely is the problem, because without instructions Octave wouldn't be doing anything
 
> Problem: In short, after repeatedly executing a script (which contains the body of an iterative algorithm) at some point Octave warns me, that some function's return value list is not fully defined (i.e. warning: FUNCTION_NAME: some elements in list of return values are undefined). However, running the function as a script mostly resolves the issue (see below for details). Restarting Octave solves the problem, but that is no viable solution.
I think the iterative procedure dies/exits without setting some return values first
nice Heisenbug, though
 
he's probably got some pretty severe scoping issues
maybe some globals
 
fortunately we're in no position to help them
 
nope
 
7:56 PM
@excaza This typically only happens when there are errors in your code, or when you're writing values improperly. So I'd check those and see if that's the problem.
 
8:11 PM
@AndrasDeak In seems to be a list of strings
In [10]: a = [10, 20, 30]

Out[11]: 'a = [10, 20, 30]'
type(In[1])
Out[12]: str

type(In)
Out[13]: list
I thing I messed up the indices when pasting, but you get the idea
This is nice:
In [8]: a = [10, 20, 30]

In [9]: del(a)

In [10]: exec(In[1])

In [11]: a
Out[11]: [10, 20, 30]
 
interesting
In [359]: type(In)
Out[359]: list

In [360]: type(Out)
Out[360]: dict
%recall might be a safer choice than raw exec:)
exec is one of python's evals
see %recall? for details
it's an ipython magic function
 
8:40 PM
0
Q: Please, need to speed up my code, it takes ages

Yurema TeijeiroMy problem is that I have two images in 3D (parallel and perpendicular intensity images), the first coordinates corresponds to the x and y positions and the last one to time. I want initially to fit my parallel image and my perpendicular one, using convolution with IRF. I do non linear least squa...

now that is a wall of text
 
9:15 PM
Your wall of code (see the comment of @excaza) is full of stuff like Chi_Sq_r_df_bf(1+end)=ChiSq_r_df;. If you don't preallocate, no wonder it takes ages. Try guessing the final size of your arrays, and increment a counter index. Allocating memory step by step, 10k times, indeed takes ages. — Andras Deak 42 secs ago
 
9:57 PM
hmm, a user was removed who apparently gave me an upvote
If you're supposed to do it, why don't you do it? — Adriaan 12 secs ago
 
not even a question in there
 
those come up more and more lately
I want to do X, here's my code, here's my image.
soooo, what's wrong with it?
 
close as unclear
 
would've been better, I used TB
 
I know
 
10:07 PM
left a bit of a better comment
 
10:21 PM
@Adriaan Sadly, the world will never see it.
 
worth a try
incidentally, OP added the "How could I perform this task?" question to his question, making it too broad rather than unclear, but it's still deleted
 
10:38 PM
@AndrasDeak good that it's deleted, I see I made a grammatical error :O
 
let me undelete...
oop, OP undeleted already
 
well, dumped another comment.
Will leave it at that I guess
 
@AndrasDeak I know, that's why I chose it :-P I started with eval, but that was too softy (doesn't seem to be able to execute assignments). I wanted the real wrecking-messing-allmighty one
 
@AndrasDeak Hey, that's very powerful! Thanks. I assume it only works in the interpreter (as opposed to in programs)?
@AndrasDeak Am I right in assuming exec can do all that, and more?
 
10:48 PM
Yeah, I think exec is easier to abuse
 
i went to watch sumo and found they've had an earthquake and tsunami in Fukushima
 
but I don't usually go close to these guys:P
@beaker :/
@LuisMendo not even in the interpreter, but specifically ipython
so yes, it's specific to that, not in programs
 
Got it. Thanks!
 
no worries:)
 
@beaker With all those sumo wrestlers together what did you expect...
:-P
 
10:56 PM
yeah, but they're on a completely different island! :)
 
We're all on the same big island, floating in the infinity of space, duuuuuude.
 
Ah :-)
 
how far out is that
 
and they were hopefully all sleeping at the time... the earthquake hit at 6am
@AndrasDeak hehehe
 
does Trump believe in the existence of Japan?
(in case you wonder: associative chain went Fukushima -> disaster -> radioactive waste -> cancerous fish with questionable causal relationship -> stuff Trump believes)
 
11:19 PM
@AndrasDeak sure he does, they're competition
 
11:31 PM
What is your question? You forgot to ask one. — Adriaan just now
@AndrasDeak there's another one ^
His two other questions on the network (mathematics.SE), also both not contain a question, just a statement
 
there's almost a question in there, but it's unclear
 

« first day (509 days earlier)      last day (2703 days later) »