« first day (1566 days earlier)      last day (1669 days later) » 

5:05 AM
Did anyone solve this MATLAB puzzle?
 
 
3 hours later…
8:34 AM
@LuisMendo yup, they can edit
 
9:25 AM
@AndrasDeak That's a bit unsettling :-)
 
Not really, they can remove problematic things from an otherwise useful comment. Mind you they mostly do this on meta, and very rarely. On main you almost ever just see them get deleted. And when they do beyond trivial things they often lead editor's remarks in the comment to show they were edited
 
@CrisLuengo What's the puzzle about? Try to generate the sequence? If code length is not limited, a literal would do...?
 
9:57 AM
@CrisLuengo the only ones are probably constant time algorithms :D
this function is really ugly
 
 
2 hours later…
12:03 PM
figure
h1 = pcolor(T_sol(1:size(BN_coh,1)), 1:CD, BN_coh.');
% h1 = imagesc(T_sol(1:size(BN_coh,1)), 1:CD, BN_coh.');
h1.EdgeColor = 'none';
ylabel('Carrington day [-]')
xlabel('Period [sol]')
h1.Parent.XScale = 'log';
title('Squared coherency of B_N')
caxis([0 1])
cbar = colorbar;
ylabel(cbar, 'Squared coherency [-]')
Where the imagesc plot is top, and the pcolor plot bottom.
The problem in the top plot I asked about here before; my numbers are overlapping the axis, and I get xticks on the top axis for some weird reason. Hence, I opted for pcolor after that.
Doing now a test with very few bins, I notice that pcolor actually colours vertices, not faces.
How do I get pcolor to color faces? Is my sole option to somehow find the "vertices" (on my logarithmic axis, jay), and plot using that grid?
 
can't you just fool it by passing a dummy row/column?
I think this ties in with the fact that it eats one row and column in your data
 
Yea, the right column is eaten, looking at the figures
feeding it nan-columns oesn't work unfortunately
BN_coh_plot = nan(size(BN_coh)+1);
BN_coh_plot(1:end-1,1:end-1) = BN_coh;
figure
h1 = pcolor(T_sol(1:size(BN_coh,1)+1), 1:CD+1, BN_coh_plot.');
That works
Köszönöm @AndrasDeak
 
12:22 PM
make sure the data looks the same as with imagesc, these face vs edge things can be tricky
 
Or fix my MATLAB installation to not mess with the logarithmic imagesc
apparently it doesn't do the weird axis-thingy with others (both in this chatroom iirc and my bosses)
 
are you sure that's not an actual matlab bug?
I don't remember what we ended up deciding
would depend on version and OS of course
 
others didn't have the problem iirc
 
I see
 
Probably something weird with the Ubuntu video drivers and MATLAB not working together as planned
 
12:27 PM
but it's an oddly specific manifestation in that case
 
12:58 PM
@LuisMendo There are no instructions. You need to figure out what is in the data. There’s a message of course. Apparently Doug at MathWorks uses this to see how candidates think and how they use MATLAB.
 
I see. I may take a look at it later. Those non-integer numbers are ugly
Hah. Got it
Hint: I first heard about the trick in Carl Sagan's Cosmos
 
That was pretty fast. You didn’t stop at the message that says “keep going”, right? :p
 
Hm. I did...
So there's more?
 
Just a bit more.
 
Ok, let's see...
 
1:11 PM
I like this type of challenge. I bought this deck of cards recently. It comes with a similar type of puzzle, where it just says “figure it out”. That was a good two hours of entertainment including a bit of googling for hints... :)
 
seems very posh
 
@CrisLuengo Got it now. Those decimal parts had to mean something...
I'm a few years late for the T-shirt I guess :-)
But I already have one anyway...
 
2:19 PM
@LuisMendo nice! They once set me a baseball cap out of the blue. That’s the only MATLAB parafernalia I have.
 
2:52 PM
hm, one of my courses has lecture slides (PDF) of >80MB each. This makes them very slow to load in the document viewer, as well as the DV crashing when trying to print it...
 
Are you using evince? Try mupdf, that's very light-weight
I bet it has a detailed vectorized plot, if you have something like 100k points on a figure it will easily take forever to load
 
@AndrasDeak as far as I can see it's mainly due to huge figures of planets. Probably those things were 4000x4000 pixels originally or something
 
could be, yeah
 
mupdf still takes a bit of time, but works faster, thanks
it doesn't have a print capability though, or am I overlooking something?
 
2:59 PM
@Adriaan hmm, yeah, could be :D
what's that "DV" that crashes when you try to print?
 
Mar 13 at 12:20, by Luis Mendo
Careless wording deserves downvoting
 
@AndrasDeak not sure yet; I wanted to print it 4 slides per single page. That took a while to set up, so I went to make tea. When I came back evince had closed itself, and nothing was printed. I'll try again and look more carefully at what happens
 
@LuisMendo Well, this can mean it doesn't have a syntax error. MATLAB does do JIT, does it not? :P
@Adriaan literally what the heck is "DV"?
 
@AndrasDeak document viewer. Sorry.
 
@Adriaan you can print from the command line like a boss
it's not trivial, nor pretty, but it might work :D
 
3:02 PM
@AndrasDeak meh, it was a quick-fix for the document loading slowly. Using mupdf that's (mostly) solved anyway
 
yeah, that's why I didn't remember the printing; I've only ever used mupdf for reading
 
3:37 PM
@AndrasDeak I consider JIT part of the interpreting :-) The user need not know that JIT is going on under the hood; and definitely doesn't press a "compile" button. Or they do, and then it's MEX and it's a whole different story. That's why it's so confusing
 
4:10 PM
@n350 You need a minumum reputation (50 I think) to be able to comment on other people's posts — Luis Mendo 15 mins ago
^^^ Does that apply to commenting on answers to your question too? I was pretty sure it didn't.
 
it does not
 
I wonder why that person couldn't comment on my answer. I suspect they might not have tried...
 
This says
> Please note that you can always comment on your own posts, and any part of your questions. However, commenting on other people's posts is a privilege gained from earning reputation
I interpreted an answer as "other people's posts"
But I'm not sure
It would make sense that anyone could post on answers to their question. But the above seems to say they can't
 
> Please note that you can always comment on your own posts, and any part of your questions.
I think "any part of your questions" intends to address answers on your questions
 
I agree that text is not as clear as it could be. How about writing "and any answer to your questions" or something explicit like that?
 
4:20 PM
it's as clear as mud though
 
@AndrasDeak Could be. Very poor phrasing then
Ninja'd
I deleted my comment
@CrisLuengo In any case I agree with the "moving target" part. No fun at all
 
I went back through my inbox, and found a comment on an answer of mine by a user with (currently) 18 rep: stackoverflow.com/questions/58309041/…
So yes, they can comment, and yes, the docs are clear as mud.
 
Thanks for clarifying!
@CrisLuengo Care to propose that on Meta.SE?
 
@LuisMendo Feel free to do so.
 
4:57 PM
0
Q: Improve description of "comment everywhere" privilege

Luis MendoThe Comment everywhere privilege description currently says (boldface added): Please note that you can always comment on your own posts, and any part of your questions. However, commenting on other people's posts is a privilege gained from earning reputation [...] The above doesn't make it ...

 
@LuisMendo +1!
 
Hi all. I stepped away for SO for a while when work got busy. Back now. Do we flag things like this question with a "Unclear" flag? It is the usual here is my homework, give me the codes
@CrisLuengo I saw your A(end+1)= foo; versus A = [A; foo]; post. I always used the former but now I know. Great post.
 
@SecretAgentMan Yes, I voted to close that one as unclear. Unfortunately there not so many people around in the weekends, so those questions stay open...
I voted that because there's no actual question. "This is what I've done so far" is not a question. But there are many other things wrong with it.
@SecretAgentMan Thanks. I suspected as much at the time, but wasn't sure until I did that experiment. Was a lot of fun to see the clear difference.
 
5:27 PM
Thanks - wanted to make sure I was still calibrated to the community for flags.
I've got to do some digging in the old Q/A on using parfor with structures. A colleague of mine has run into trouble with something that would easily benefit from using parfor but unfortunately they used structures to do their bookkeeping and organization instead of cell arrays. I see there are some old questions on the subject so I expect I'll learn a lot there.
 
5:51 PM
@CrisLuengo Heh, it's already at 15 :-)
 
@Adriaan Congrats!
I still haven't even made bronze.
 
6:27 PM
room topic changed to CHATLAB and Talktave: Congratulations to Adriaan for getting the MATLAB gold badge! Room to discuss MATLAB and Octave related topics - Also... i.imgur.com/EHAPP7J.gif [matlab] [octave]
7
 
@Adriaan that is awesome. Good job <strike>Ander</strike> Adriaan.
 
@Adriaan Congratulations!
There's a bit of an uptick in MATLAB gold badges: 2016: 3x, 2017: 1x, 2018: 1x, 2019: 4x (so far)
 
6:54 PM
@Adriaan Gefeliciteerd!
 
Eskerrikasko all
@CrisLuengo the slow and steady ones are coming in this year; After 2015 SO started dying, and apart from random upshots (read; Suever) not much happend after that.
 
I'm targeting mine in 2045
 
7:21 PM
@SecretAgentMan Be more ambitious! You can get it by 2044 if you put in a bit more effort! :p
 
@Adriaan congrats to the hammer!
@CrisLuengo Depends whether you use 0- or 1-based indexing:)
@HansHirse :D
I feel honoured!
 
7:46 PM
OP seems to keep changing question and has a resistance to edit question with MCVE. I'm starting to feel this is a CV Unclear situation. stackoverflow.com/q/58382352/8239061
 
@SecretAgentMan The OP deleted it.
 
I think I was in a Help Vampire situation. Last time I go down that road.
 
I still have no idea what they were asking in the comments
 
I don't either. They kept revealing more and more details but without connecting the dots. That and an active resistance to describing the input variables.
 
8:22 PM
posted on October 14, 2019 by Cleve Moler

Today's post was inspired by a YouTube video, Why do prime numbers make these spirals?, on the channel 3Blue1Brown, created by Grant Sanderson. In my opinion this is the best math channel on YouTube. He has beautiful graphics and superb exposition. I recommend you take a look, if you haven't already.... read more >>

 
@Feeds That's actually interesting.
 
true that
 
Yeah What is that big, white swath?
 
9:13 PM
I'm not good with discrete math
primes creep me out
 
9:48 PM
Oddly, with a triangular spiral there's some structure (stripes) too:
 
Can that somehow be due to the triangle construction? How does a random point cloud look on it?
 
Not sure what you mean by "random"... this is how the triangular spiral is built (just wind around in a triangular shape)
 
Rather than putting dots at prime points, putting dots at random with p probability. But yeah, I guess that shouldn't generate such structures at all
 
Ah, I see. Let's try
 
@LuisMendo Neat. I'll have to try that.
 
10:01 PM
The above figure takes a long prime-indicator vector (zeros for non-primes, ones for primes) and wounds it in a triangular spiral, with dots corresponding to primes
To randomize, I applied a random permutation of that vector in the figure below:
The structure is lost
 
Awesome :) Thanks for entertaining my ignorance
 
The triangle draws points on an hexagonal grid. How is that translated to the square grid of the monitor?
Cool plot, by the way!
 
The loss of structure is probably related with the fact that primes may be random, but not uniformly so: they are more sparse as n increases
@AndrasDeak :-D
 
I'll just revert back to my default "primes are creepy"
 
They are!
@SecretAgentMan Wait till you see the hexagonal one...
@CrisLuengo I let plot do that
Are you thinking some aliasing may occur?
This is the code:
clear
N = 2.5e5;
n = 0:N-2;
r = exp(2j*(1:3)./3*pi);
s = [0 floor((1+sqrt(1+8*n))/2)];
x=r(mod(s-1,3)+1);
y = cumsum(x);
ind = isprime(1:numel(y));
%ind = ind(randperm(numel(ind))); % randomize
z = y(ind);
plot(z, '.', 'markersize', 4)
axis equal
Whoops, I just deleted clear all. Don't tell Ander it was there
3
 
10:05 PM
:D
you can count on me
 
you can count on me to tell him
j/k
@LuisMendo Not sure, I don't think so, unless you render the plot and then subsample it.
 
there are sometimes elusive bugs in plotting routines that lead to weird discretization
I know I've seen at least one such in pyplot
 
Anyway, the well-known Ulam spiral does have those stripes. This just uses a triangular spiral instead of square, so the stripes are probably real too
The hexagonal case is even creepier:
 
Nice!
 
wow, I bet those slanted lines out of nowhere are aliens
 
10:10 PM
I thought it would get closer to the circular one, but I guess here the perimeter is an integer, not 2pi, and so your lines always stay straight.
Where's your "big, white swath"?
 
read between the lines
 
This better illustrates how the spiral is wound, for the hexagonal case. The center is 1, which is not a prime, hence no dot, etc
 
that must be tedious to implement correctly
 
I wrote the code some time ago (when I was preparing the linked CGCC challenge), so I don't remember. But it doesn't look like it was hard to do:
clear
r = exp((1j*[0:-1:-5])./3*pi);
x = 0; %// initiallize
for n = 1:5%1:100
    x = [x r(5) repmat(r(6),1,n-1) r(ceil(1/n:1/n:5))];
end
y = cumsum(x);
plot(y, 'k.-')
hold on
z = y(isprime(1:numel(y)));
plot(z, 'bo')
 
posted on October 14, 2019 by Steve Eddins

Back in the summer I had another chance to use the Color Thresholder, a very nice app that's in the Image Processing Toolbox. I happened to come across a question on MATLAB Answers - someone was looking for a way to segment the yellow region in this image:... read more >>

 
10:15 PM
Hmm, yeah. I'd have guessed that there's no easy math trick to generate it, but that looks otherwise
 
^^^ You can tell it's old because of the %// :-D
 
Complex numbers are the main trick here
Each iteration in the for loop adds a turn in the spiral
 
neat
 
I think that's what it does. You know what they say about former-self's code...
I got two silver badges on meta.SE with my complaint about the privilege wording :-)
I feel I should share those with you @CrisLuengo @AndrasDeak
 
10:21 PM
ha, well deserved for you! ;)
 
Nah, it's all yours for putting in the effort to type up a question. :) Congratulations!
 
I'd never have bothered
 
:-D
 
@LuisMendo What is that %// about? I haven't seen that before. An Octave thing? Or an SO thing?
 
SO old syntax non-highlighting thing
you had to fool the highlighter that % is a comment by appending a c++-style comment
 
10:22 PM
Then Amro's syntax script was incorporated into SO and fixed that
 
it only took, what, four years of begging?
 
Yup :-)
13
A: Add syntax highlighting for the MATLAB language

OdedMatlab syntax support is rolling in. This is basic syntax support without keywords, as these add a lot to the size of the highlighter and do not gzip well at all. Still - comments should be comments and basic highlighting should work as expected.

 
Ah, yes, ' was even more fun back then. It was misinterpreted as string opening/closing:
Finally I can answer questions without appending // to comments or having to worry about transposing as "stray comments"... and block comments, yes! — rayryeng May 24 '16 at 14:36
 
%'// the uberhack? :D
 
10:26 PM
And then it took 2 more years for Octave to get syntax highlighting. meta.stackoverflow.com/questions/361897/…
 
Well that's surprising, given that it's (more or less) the same as Matlab's!
 
@CrisLuengo at least that only needed a mod flicking a switch
@LuisMendo nobody realized that I think
 
Yes, that one was trivial.
 
so this would mean that endfor and #-comments are broken in octave :P
 
Yes, they don't highlight correctly.
Nor does the "-style strings.
...which since has become a problem with MATLAB code too.
 
10:28 PM
hmm, then neither do matlab strings
not a real loss of course
 
Yes, if it doesn't run correctly in MATLAB 5.3, I don't care for it. :p
 
Haha
 
I hate MATLAB strings with the passion of someone who doesn't use MATLAB at all
4
 
LOL!
 
10:29 PM
I hate them with the same passion
I was initially wary about tables too, but now I love them
tables really fill a gap. strings don't
 
yeah
 
Strings are objectively better than char vectors, but adding them has just made things more complicated and confusing.
 
I might agree if you could slice them properly
 
If char vectors hadn't existed, and they proposed char vectors or strings as a new feature, everyone would have picked strings, I think.
@AndrasDeak Can't slice them?
I've never used strings, so I have no idea what they're missing...
 
last time I checked, which was a very long time ago, you could only slice them using javaish methods or some struct trick
then again knowing how well python handles strings my bar is set pretty high
 
10:33 PM
Ah, indexing into them. Yes, that would be a problem...
There's no MEX interface for strings, so I stay away.
 
@AndrasDeak You sort-of can, but it's ugly:
 
to be fair before string came my stance was "MATLAB handles text as well as fortran does". Which is something :D
 
>> str = "abcd"
str =
    "abcd"
>> str{1}(2:3)
ans =
    'bc'
 
right, not struct trick, but cell trick
 
{} indexing turns the string into a good ol' char vector
 
10:36 PM
yay? :P
 
which can then be indexed into
:-)
 
@LuisMendo Oh, so you can ignore the existence of strings and just treat them like cell arrays of char vectors? That's pretty neat. Except iscellstrprobably returns false...
Googling "site:stackoverflow.com matlab convert struct to matrix" returns 7890 results. Why this question? stackoverflow.com/questions/58384919/…
 
11:04 PM
@CrisLuengo Yes, you can do that. They use a little less memory, though
>> str = ["abcd" "QWERTY"];
>> str_2 = {'abcd' 'QWERTY'};
>> whos str*
  Name            Size            Bytes  Class     Attributes

  str             1x2               196  string
  str_2           1x2               244  cell
 

« first day (1566 days earlier)      last day (1669 days later) »