« first day (312 days earlier)      last day (2909 days later) » 

1:12 AM
grumble grumble
question:
-3
Q: converting this matlab code to C

Varun DanduI'm trying to convert a matlab code to C manually and listed below is one of many functions from the code. Please convert this one for me and it will help me get build an idea and get started with the work MATLAB code: function cosAngle = cosAngle (u, v) cosAngle = dot(u,v)/(norm(u)*norm(v)...

my comment:
Heh. I mean, Stack Overflow is not a code writing service. Look at the documentation, MATLAB has a really good one. Look at what the components do; everything should be straightforward. If you don't know MATLAB, it won't work out anyway. Same for knowing C. — Andras Deak 52 mins ago
answer by reputation whorputation:
-1
A: converting this matlab code to C

Zheyuan LiOn your request, here is the function in C you want. The comments should be informative. double cosAngle (int n, double *u, double *v) { /* local variable declaration and initialization */ double dot_product = 0.0; double norm_u = 0.0; double norm_v = 0.0; int i; double u0, v0; /* ...

In my personal opinion, answering questions like these are not helpful. OP will have to learn both C and MATLAB to translate their code (or at least read the MATLAB documentation...). Your function won't teach them either. However, by giving askers like this what they want (rather than forcing them to learn the languages they use, or paying for someone to translate for them), you don't make them solve their own problems. Soon they might try to have the full code translated question by question. — Andras Deak 1 min ago
now, comment on question by said rep.whor.:
HAH, it's been flagged and deleted! NIIICE:D
iharob is (probably) my hero
 
 
9 hours later…
9:50 AM
Hi all! Any interesting Q or A lately?
 
As usual, nothing but RTFM questions.
 
I'd like to think that at least once in a while there's something new and exciting :)
 
10:21 AM
At least tomorrow something exciting is going to happen=)
Transit of mercury
 
@AndrasDeak "I like C programming, physics and coffee", well, I'm not sure about the former, but the latter two I fully agree on
 
@Dev-iL finally something our resident lobster can help out on! (cc @ball)
@AndrasDeak that one's been deleted, probably through the queue with help of my comment
 
10:50 AM
@Adriaan Well, if he'd express interest in contributing to certain open-source projects, we would have something to talk about.....
Btw, where have you been last week?
 
@Dev-iL Monday up to my knees in off-shore mudflats, Tuesday and Wednesday at home, Thursday drinking beer in Amsterdam, Friday up to my knees in cow shit at a dairy farm, yesterday at home
 
Sounds... Eventful :)
 
jup, was a fun week
 
11:40 AM
Hi how can I do a correlation matrix in this code
 
Correlation of what?
Have you tried using corr?
 
@flawr he's been asking this single sentence over the last week, we still have no idea what he wants
 
He probably wants a perma ban then.
 
@flawr mwoah, we're usually not kicking anyone from the chatroom (there've been cases like this before). Question ban on SO might happen if their questions get deleted all the time.
 
I was not being too serious=)
 
11:52 AM
@flawr correlation between A matrix and x
 
@KarGar So did you try corr?
 
yes
does not work
 
Why not
 
it says : Error using eig
Input to EIG must not contain NaN or Inf.

Error in conv (line 13)
[U,D]=eig(Ry); % räknar ut egenvärden och egenvektorer
the eigenvalues and vectors could not be computed
 
0
Q: Need help building function using MATLAB

NeelIn my recent project I am trying to plot the amplitude and phase response of a complex transfer function. One part of the transfer function includes the following term. Could anyone help me how to proceed? I am stuck in the summation part. A_k(z)p^k For k = 0 to M

hum, what to do with this
2.1k rep asking for gimmeh codez
@KarGar the error clearly states what's wrong; there are NaN or inf values around
 
12:08 PM
@KarGar Make sure you dont have any NaNs or Infs.
@KarGar If you want people to help you you need to give all the necessary information you have. If you just say "it doesnt work" nobody is going to be able to help you.
 
@flawr Iam trying to fix it now ...
@flawr do you have any idea about sound separation in matlab ?
 
Probably not, as I've never heard of that term.
 
you use algorithms to separate two sounds from each other
 
@KarGar doesn't tell me much. I could just cut the entire signal in half in the time domain and Ive separated them...
 
What defines a sound?
 
12:18 PM
I have one algorithm to implement and I did and I used instanous sound and I could separate it but the convolutive mixture was hard to separate because I need to do filtering and one more staff but I can not discover it
mechanical vibrations
@Adriaan the thing that I have to use a specific algorithm for that
my algorithm is called : The nonlinear recursive least-squares learning rule
I used it for instanous mixture and I successed
but I did not successed in convolutivve mixture
in convolutivve mixture I have to do filtering as I did in my code I posted
then I have to do a correlation matrix for observing the coefficients of my A matrix : this is not clear for me and that is why I failed
 
Do you by now know what exactly is a correlation matrix?
 
not sure
I can not understand it
 
then you'd better find that out first
 
I found some pages about that but was not helpful
 
it's easier to learn how to drive a car if you know what a car is
 
12:27 PM
that is ture man
 
 
2 hours later…
2:06 PM
@Adriaan I would like to remove the third dimension via the segmentation mask process, so that the results is the image thresholded to any given value I choose — Sari 7 mins ago
that still doesn't make sense right? Cause you'd end up with a 3D binary matrix afaik
 
 
1 hour later…
3:23 PM
@Adriaan nice
the one I bitched about got self-deleted by OP
@Adriaan nope, deletion does not factor in unless it's an answered question
downvoted questions matter, regardless of deletion status
 
 
1 hour later…
4:31 PM
I am so stack, so if anybody knows something about my question, please, I would like to answer me! — panos deemac 17 mins ago
one could say he's...overflowing on stack
 
@KarGar Please stop asking questions here. If you have an actual question, please create one.
 
@rayryeng he did, it was DVed and CVed as unclear in no-time
 
lmao. at least he tried.
 
isn't kicking a tat harsh? We didn't even kick Abishek
 
I've also kick-muted him.
Really? I did once!
I don't think the guy was here anyway to give him the kick :P
was a pretty useless one.
 
4:37 PM
@Adriaan Abishek, while certainly annoying, wasn't repeatedly asking the same question despite being told this isn't the appropriate forum
 
@excaza That is true.
I find this particular user extremely annoying. Abishek was tolerable.
@Adriaan did he actually accept your answer? Did the apocalypse happen?
 
while I can certainly sympathize, I hate being stuck on the same problem without knowing where to go to for the answers, it still can get obnoxious
 
8
A: PCA in matlab selecting top n components

AdriaanForeword I think you are falling prey to the XY problem, since trying to find 153.600 dimensions in your data is completely non-physical, please ask about the problem (X) and not your proposed solution (Y) in order to get a meaningful answer. I will use this post only to tell you why PCA is not ...

See the green there?
 
Yeah I remember that one lol
funny how the other person got the bounty yet your answer has more votes.
Probably happened over time
 
@rayryeng his had +5, mine had +3 at the time iirc
his had +4, mine had +2 at the time apparently
 
5:00 PM
@ballBreaker latest song from Death Angel hit joeptoep last week:
I like their drums a lot
 
5:10 PM
@rayryeng how's it with the fires in Canada?
 
They're still pretty bad
 
you're far off right?
 
some friends of mine were planning to go to Lake Louise this summer... doesn't look promising
 
well, the lake can't catch fire so it's still ok!
unless there's fracking nearby...
 
5:26 PM
hmmm... I wonder where the Alberta Tar Sands are...
 
WHOO! Gas extraction! WHOO
 
wow, I thought =@( was a hypnotized beaker...
the things you learn on SO
 
@beaker Such a shame that all we can do about RTFM is down vote
chap has 1300 questions o.0
 
5:51 PM
I've created a MATL room to keep information centralized @Suever @David @beaker @rayryeng
3
 
big-time! :D
 
\o/
I was tempted to user your name
"MATL chatl"
 
lol
 
pinned it
 
@LuisMendo does that mean we won't be seeing you around anymore? :(
 
5:53 PM
@AndrasDeak I see. Thanks! Forgot to ping some of you guys, sorry
@Adriaan By no means. It won't be that easy :-P
 
oh, don't worry about it:)
I'm just an intermittent bystander MATL-wise
 
@AndrasDeak MATL doesn't count as a programming language. So you can use even if (you say) you are not a programmer :-P
 
oh, good to know:P
 
6:18 PM
Splendid this. The "Goal scored" song of the Swedish team at the world hockey championships is Abba
 
dancing queen?
 
@AndrasDeak and Mama Mia
anything Abba it seems
I'll let you know if they've got more when they score next
@AndrasDeak the Hungarians were rather satisfied with their 7-1 loss against Canada today; they scored their first goal in 78 years against them :P
 
I can see why, that's some feat!
we're not exactly the hockey world champions
 
not exactly, no :P
@AndrasDeak please remind me to check this question in a bit. OP already deleted/undeleted once
I told him his question lacked loads of info to be answerable, that triggered the second self delete probs
 
6:24 PM
I can only see the title url, but that's already too much
 
@AndrasDeak I CV-plsed it in the SOCVR not too long ago
 
>:D
 
@beaker Armenians at the Stockholm palace, lol
 
@David Yes, Suever prepared a very nice script that does that
Apr 28 at 13:50, by Suever
@LuisMendo Just updated the script to handle # usage. I'll clean up the script because there are a few issues but hopefully this gives you a general idea.
I think that's not the newest version
 
ah, OK
@Adriaan oh yeah I can see, thanks
 
6:31 PM
@ballBreaker how was the breaking of balls this weekend?
@AndrasDeak darn, no Abba on this goal
 
@Adriaan done
 
@beaker thanks lad
0
Q: Executing time for MatLab function in parallel

OrangeblueI am currently working on parallel timing function, as a timing threshold, that can be applied to the main function. A maximum running time is needed. Once the threshold is reached, the mainfuntion would break and enter the next loop. My original idea was to call "timer" from another independent ...

So. Much. Nested. Loops.
 
much loop. many iterate.
 
Seemed like a good place to advertise myself once more
 
7:02 PM
hm... seems like a good place for a timer callback, but i've never used them in matlab
 
@beaker might as well leave a more helpful comment than my blatant self-promotion
 
@Adriaan I'm RTFM-ing
 
tim seems to know things about this
 
i think tim was involved in the OP's previous question about this
nope, i must have misremembered
 
7:19 PM
@David BTW G now takes one input implicitly when clipboard G is empty. Thanks again for the suggestion!
 
@LuisMendo How does this differ from i or j? Or is it just that you can loop over the same code and with an implicit input in the first iteration?
 
@beaker Oi! Head over to the new room :P
 
@Adriaan Oooh, now I get to discover whether I can link to a comment in a different chat room ;)
 
@beaker permalink, copy that :P
 
@Adriaan that's no fun
 
7:33 PM
I'm looking forward to on stackoverflow=)
 
@flawr I don't think they're ready for MATL ;)
although there are a couple of questions I was tempted to answer in MATL
 
But we are ready=)
We were born ready.
We could make a stackoverflow clone exclusivley for MATL and call it STACKL
 
@flawr LOL
 
@beaker Yes, imploicit input in the first iteration, and just push that same input in following iterations. (Up to now, G did nothing if no previous inputt had been taken. Now it implicitly takes an input, and pushes it)
Example:
>> matl 4:"G
> 'test'
test
test
test
test
@flawr :-DDD
 
@LuisMendo okay, that makes sense
 
7:48 PM
@flawr BTW, there's a new room for MATL: chat.stackexchange.com/rooms/39466/matl
 
@LuisMendo Do you think this room will ever be used?=)
 
@flawr This one? Of course! It has a lot of activity. About the MATL one I'm not so sure :-)
But it's probably better to have it, to keep information centralized
 
@beaker I first read "puppet" as "muppet", but here you go anyway
 
@AndrasDeak LOL... obviously scared shitless ;)
 
8:18 PM
in MATL on The Stack Exchange Network Chat, 12 mins ago, by flawr
You missed the opportunity to call this room CHATTL
 
9:14 PM
Check out numpy.histogram. It's very fast, too. — roadrunner66 3 mins ago
almost 2k rep and posting crap comments -.-
reminds me of our "R evangelist"
 
Well, numpy is fucking awesome. Just sayin'
 
@AndrasDeak idgaf. It's not MATLAB so it ain't helping the OP
 
obviously
bah @beaker you're right, I made a false association by glancing at the question
I didn't realize that OP really just wants a histogram
 
@AndrasDeak either one works
but with edges you can satisfy the zero-count requirement
 
well not on my level of accumarray:P
@Adriaan you can leave a MATLAB-suggesting comment on their most recent question from 2013;D
 
9:19 PM
@AndrasDeak @beaker the moron posted it as an answer >.<
pls DV that shit to hell
nvm, self deleted
 
another interesting possibility is sparse
although that doesn't allow negative values
 
wat?:D
oh, the numpy one
lol
I missed it
I think they just thoroughly misread something......
nobody can be this stupid
wow, what a crap repwhore answer OHMYGOD IT'S YOURS ADRIAAN I'M SO SORRY
*downvotes*
 
@AndrasDeak go ahead :P
 
nah, the histcounts version saved your poor pink ass
 
@AndrasDeak Do you like numpy?
 
9:28 PM
@AndrasDeak apparently that also works for 2D matrices. Well, I guess that concludes my answer
 
@flawr love it:)
though I would think that "numpy is fucking awesome" is a dead giveaway;D
lol:D
 
@flawr I presume he does, having a wife and all.
so @AndrasDeak when's the baby coming?
 
@Adriaan it's not necessarily related, but yeah
@Adriaan I have no idea, fortunately
 
@AndrasDeak I'd appreciate a ping by the time it does happen. Wouldn't want to miss out on the baby photo battle with ray
 
lol
 
9:40 PM
I'm off to bed now, got another enervating class on AQM tomorrow morning
 
don't hold your breath
sleep well
 
@AndrasDeak I can hold it for a very long time
 
@Adriaan then be my guest:P
 
@AndrasDeak thanks! When in the summer does it suit you? I don't have plans yet
and is it OK if I bring the missus as well?
 
figuratively speaking
from afar
if you know what I mean
 
9:41 PM
lol
 
9:51 PM
can someone double check some code for me in MATLAB? it's working in Octave:
0
A: Is this bit conversion process vectorizable? (MATLAB)

beakertypecast is vectorized, so you can just feed the entire input array to it. (Note that input is the name of a built-in function, so you should really name your variable something else.) The result is a column vector, so you need to reshape it afterwards. >> N = 10; >> A = uint8(randi([0 255], 12,...

 
sure thing, just a sec
 >> shape(typecast(A, 'single'), 3, [])
Error using typecast
The first input argument must be a vector.
:(
 
@AndrasDeak thanks, I'll update my code
 
Same here
 
easy fix anyway
 
Y=TYPECAST(X) (...) X must be a scalar or vector
 
9:55 PM
how about reshape(typecast(A(:), 'single'), 3, [])?
 
>> reshape(typecast(A(:), 'single'), 3, [])

ans =

   1.0e+38 *

   -0.0000    0.0000    0.0000    0.0000   -0.0000   -0.0000    0.0000   -0.0000    0.0000    0.0000
   -0.0000   -0.0000    0.0000   -0.0000    2.1023    0.0000    0.0010    0.0000   -0.0000   -0.0000
   -0.0001   -0.0000   -0.0000   -0.0000    0.0000    0.0000   -0.0000    0.0000   -0.0000    0.0000
 
that looks a bit odd
 
yup...
how about just single(A)?
or is that the point of the question?
 
doesn't do the same thing
OP is trying to convert 4 uint8's to a float
what input did you use?
like, what were the first 4 values?
 
What the heck: typecast(uint32(bin2dec(num2str(reshape(dec2bin(...
 
9:59 PM
>> A(1:4)

ans =

  208  231   32  233
 
here's what i get:
typecast(uint8([208  231   32  233]),'single')
ans =   -1.2158e+25
 
>> typecast(uint8([208  231   32  233]),'single')

ans =

 -1.2158e+25
2012b powa:)
octave:2> typecast(uint8([208  231   32  233]),'single')
ans =   -1.2158e+25
nevermind you got the same
 
Well recently typecast(andras_deak,'married')
 
@beaker it's just that in the middle of the matrix there's a huge value, scaling the output
@flawr that we did:)
 
@AndrasDeak okay, so the random values are throwing it off
 
10:02 PM
yup
 
okay, I'll update the answer... thanks :D
 
no prob:)
sorry for the confusion
 
no, i should have figured out more coherent test data
 
yeah, it's your muppety fault, clearly
 
obliviously
 
10:08 PM
:D
 
10:53 PM
@flawr You are inspired tonight :-)
 
someone might have misstarred:P
 
11:08 PM
@Divakar So why did you skip the bsxfun aproach here? :-)
2
Q: Count the frequency of matrix values including 0

SariI have a vector A = [ 1 1 1 2 2 3 6 8 9 9 ] I would like to write a loop that counts the frequencies of values in my vector within a range I choose, this would include values that have 0 frequencies For example, if I chose the range of 1:9 my results would be 3 2 1 0 0 1 0 1 2 If I picked...

 
hey Luis! For performance :) @LuisMendo
Also one could use that hackish way to initialize with zeros : out(maxN) = 0.
 
... faster than bsxfun? I thought only matrix multiplication could! :-)
BTW, it's 3 bytes in MATL :-P
 
what is 3 bytes in MATL? bsxfun?
 
The whole code sum(bsxfun(@eq, A.', B))
 
ah! wow!
 
11:14 PM
! is tranpose, = has automatic bsxfun, s is you guess what :-P
 
Don't tempt me to go that path!:D
 
@Divakar That's exactly what I'm doing
Forget about performance
Go for fewest bytes!!
:-D
 
haha
There's even a fastest-code tag in CG site. How does that tag work with shortest byte code?
 
@Divakar They are exclusive
Fastest-code is just that. Byte count doesn't... count
 
So, in that tag, they don't care about shortest code?
ah I see
 
11:17 PM
Exactly
Here's a recent, very impressive answer
49
A: Calculate the number of primes up to n

DennisC, 0.026119s (Mar 12 2016) #include <math.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #define cache_size 16384 #define Phi_prec_max (47 * a) #define bit(k) (1ULL << ((k) & 63)) #define word(k) sieve[(k) >> 6] #define sbit(k) ((word(k >> 1) >

(I have no idea how it works)
 
yeah! I would hope lots of C code for that tag
 
Good ol' C is probably one of the fastest, yes
 
or assembly? :)
 
:-D
 
@Divakar sparse will beat you all!!! muahahaha!
 
11:30 PM
I am afraid so!
 
@beaker Good idea! It's essentially like accumarray!
 
@LuisMendo yeah, you just have to give it a dummy second (or first) index
 

« first day (312 days earlier)      last day (2909 days later) »