« first day (3012 days earlier)      last day (353 days later) » 

6:20 AM
0
Q: manipulate 2d gaussian in matlab

sharon shenI wish to plot 2d gaussian in matlab, and here is the code and generated graph. x=0:.02:1; y=x; r = 0.2; %set standard deviation [X,Y]=meshgrid(x,y); Z=exp(-((X-0.5).^2+(Y-0.5).^2)/(2*r^2)); mesh(X,Y,Z) colormap([0 0 0]); Since we can get a 2d gaussian from multipying two 1d gaussian: I w...

Do we have a dupe for this? Mad Physicist is right, AFAIK, they just missed the dot
Someone VTCed as a typo, which I'm not entirely convinced of. Typo would mean that they know what they were doing, just missed a character here or a symbol there. This is a fundamental operator they missed. I'm fairly sure we have a dupe target somewhere
OTOH, they do use .^. They might just have copied that out of the docs though
 
7 hours later…
1:02 PM
Again, MATLAB's stupid hard-wired 1-based indexing strikes again. 30 years ago I was trying to get them to make the index base a parameter of an array that can be changed to any integer. So even negative indices, as well as 0, could be accommodated. Even talked with Cleve Moler about it once (back in the '90s). Advocacy fell on deaf ears. — robert bristow-johnson 12 hours ago
@Adriaan borderline, and definitely unlikely to help future readers
Similarly borderline dupe: stackoverflow.com/questions/15810349/…
@AndrasDeak--СлаваУкраїні ghe
I get 0-based from a programming/CS point of view, but why is 1 any worse and, which I don't understand at all, use negative indexing? You could even map whatever you want, 0-based, negative numbers, camels, to an indexing array in itself.
Beats me
I assume it might seem practical in some cases, when indices translate directly to physical properties.
Well, yes, but again: use an indexing array. Indexing into the array is a CS-thing, which in turn can represent physical quantities easily.
Sounds like something that should be a custom class rather than syntax
 
9 hours later…
10:35 PM
@Adriaan Arbitrary indices is a terrible idea. You get all caught up in the "why is 24.0000 not the same as 24.0000?" thing. And if you can't use floats, why try to attach any meaning to the index other than position within the array?
@Adriaan There's tons written about why 0-based indexing is better than 1-based indexing, but I don't totally buy those arguments. I think it depends on the application. For matrices, for linear algebra, 1-based indexing is more natural. For signal processing, 0-based indexing is more natural because we usually define the FFT and similar transforms with n=0..N-1.
I think that is why Robert prefers 0-based indexing, he's a DSP guy.
10:50 PM
yeah, some patterns are nicer with the one, and others with the other
the main issue with 1-based indices is that very few languages do it so it's a pitfall for most people who know how to code
developer brains' pattern matching is underrated
(see also: definitive coding conventions)
@CrisLuengo linear algebra minus polynomials :)
@CrisLuengo Exactly. And that's why this user shouldn't say "stupid hard-wired 1-based indexing". FWIW, his proposal to have variable-base indexing seems much more stupid to me. But I wouldn't say it is stupid. It might have some uses

« first day (3012 days earlier)      last day (353 days later) »