So I'm back here again. Same girl who pulled an all-nighter last week trying to write a program in MATLAB. It's happening again. Only this time I need to be in a research lab at 8 AM, so I have even less time.
Anyway, this program runs perfectly. It calculates power, equivalent resistance, etc. The problem is simple and it's one I've had constantly. How do I get the three row vectors to show up as columns side by side as a matrix instead of as one long column vector? They did an example in the book that did this, but when I used those commands, it didn't fucking work. Here's the program:
clear all;
v=input('Enter the source voltage: ');
nresistors=input('Enter number of resistors (must be >0): ');
R=input('Enter resistance of first resistor (must be >0): ');
n=1;
sum=0;
Ptotal=0;
while R>0&&(n<=nresistors)
resistance(n)=R
sum=sum+(1/R)
current(n)=v/R
Power(n)=v*(v/R)
Ptotal=Ptotal+(v*(v/R))
n=n+1
if n>nresistors
Requiv=1/sum;
sourcecurrent=v/Requiv;
Final=[R'; current'; Power'];
disp(' RESISTANCE (/omega) CURRENT (A) POWER (V)')
disp(' ')
disp(Final)
fprintf('The source current is %f A and the total power is %g V.',sourcecurrent,Ptotal)
quit;
end
R=input('Enter resistance (must be > 0). : ');
end
n=n-1;
if n==0
disp('Error: No values entered for resistance.')
end
The problem is in this line: Final=[R'; current'; Power']; Thank you! Btw, I'm aware I need semicolons and I probably could have done this more efficiently. The semicolons are missing because I was testing this shit and it's not efficient because I'm clearly a noob.
Name:
Laur2013-01-25 4:41
Well, it works perfectly except for that the quit command apparently just makes MATLAB close instead of just making the program end. Awk.
Name:
Anonymous2013-01-25 4:46
LLLLEEEELLLLLLLLLLLLLLLLLLLLLLL
IM TOTALLY A GIRL DO MY HOMEWORK BOYZ PLS
but the break might not work there either..?
replace quit / break line with R = 0 and it should be fine =)
Name:
Anonymous2013-01-25 5:36
this is obviously a lie, as in any electrical engineering faculty the M:F ratio is at least 10:1, and thus even the ugliest hambeast wouldn't have to resort to begging the internet with "I'm a gurl :)))" to get her homework done with all the willing ugly engineering guys around.
>>6 ^^ perhaps their all jerks? xD or homework is for doing at home?
kind of hoping the break does work... otherwise
R=input('Enter resistance of first resistor (must be >0): '); -> R = 1
and move "R=input('Enter resistance (must be > 0). : ');" to the beginning (inside) of the while loop..?
R = R + R<1; (prevents R=0 divis by zero? // R = 0.5 from increasing voltage? // assume no negative resistances will be entered?)
Thanks you guys, at least for providing me with amusement.
I'm not a hambeast yo.
It was 5 AM. No guy or girl in their right mind, ugly or otherwise, is awake at that hour. And yes, the male-female ratio is awful. My friend Alex was helping me with the code and I showed him this thread and we could only think of one other female electrical engineer we know.
And when I said "Same girl," I didn't mean "HELP ME I'M A USELESS STUPID FUCKING GIRL WHO CAN'T CODE BECAUSE SHE HAS A VAGINA." It was more of a reference to my previous post, dickheads.
Anyway, I realized I needed to use a table command. The problem was with my R matrix. It was a matrix the entire way through but then when I entered the final resistance of 10 ohms, it went from being a matrix to a single value and so the table couldn't display because of the varying dimensions and such.
I don't even care, I submitted it 5 minutes before it was due. -_-
>>17 It was 5 AM. No guy or girl in their right mind, ugly or otherwise, is awake at that hour.
For fuck's sake, you think that's an achievement? I've been up for more than more 50 hours, and most college students have been up for more than what you claim you've been.
What's the point of mentioning the names of your friends here? They're not relevant to the conversation.
Yes, you're a useless stupid fuck because you have a vagina. This is elementary level shit. The fact that /prog/ is shit is also elementary, I don't know why you keep asking your dumb questions here. Grow a pair of balls and a penis, please.
>>17
You have yet to ever code.
Ditch that fucking K&R/FIOC pig disgusting lovechild of an eldritch abomination shit you call matlab and learn you some SYMTA.
>>17
This board is currently shit, thanks to a fascist and a neo-Nazi whose constant bullshit got almost everyone else to leave. If you're interested, you might want to read the older threads such as the "fibonacci butt sort" or the "sleepsort algorithm" threads to see what we once were. Also, you won't achieve enlightenment unless you read SICP. Also, if it ain't Lisp, it's crap. Unless it's Common Lisp, in which case it's diarrhoea.
>>18 Yes, you're a useless stupid fuck because you have a vagina.
Illogical sexist cretin.
>>21
If you're a kike and you know it, sage your posts.
If you're a kike and you know it, sage your posts.
If you're a kike and you know it,
And you really want to show it,
If you're a jewboy and you know it, sage your posts.
>>22 This board is currently shit, thanks to a fascist and a neo-Nazi whose constant bullshit got almost everyone else to leave.
No one has left except namefags.
If you're interested, you might want to read the older threads [...] threads to see what we once were.
You have no idea what you are talking about. 95% of posts have always been off-topic.
Also, you won't achieve enlightenment unless you read SICP. Also, if it ain't Lisp, it's crap. Unless it's Common Lisp, in which case it's diarrhoea.
Nice memes, but I still don't think you really know what you are talking about.
*YOU HAVE BEEN VISITED BY LE TOP LEL OF COMEDY GOLD** POST THIS IN 3 threads or lose your sides!
░░░░░░░▄▀▀▀░▄▄▄▄░░░▀▀▀▀▀▀▀▀▄▄░▀
░░░░░░░█░░░░░░░░▀▀▀▀▀▄▄▄▄▄▄▄▄▀░░█
░░░░░▄▀░░░░░░░░░░▄░░░░░░░░▄▄░░░░░▀▄
░░░▄▀░░░░░▄▀▀▀█▄░▀░░░░▄▀▀▀██▀▀▄░░░░░▀
░░▄▀░░▄▄░░▀▀▀▀████▀░░░▀▄▄▀▀▀▀▄█░░░░░░█
░▄▀░▄▀█░░▄▄░░░░░░░█░░░░░▄▄▄░░░▀▀░░░░░░█
▄▀░░█░█░▀░░▀▀▄░░░░░█░░░░░░░▀▀▀▀▀▄░░░░░█
▀▄░░▀░█░░░▄░░░░░░▄▀░░░░▀▄░░░▄▄░░▀▄░█░▄▀
░░▀▄░░░░█▀▄░░░░░▀█░░░░▀▀░█▄▀▄░█░░░█░█
░░░░█░░█░▀▄▀▄▄░░░░▀▀▀░░░▄█▀░▄▀█░░░░▄
░░░░░█░░█░▀▀▄░▀▄▄▄▄▄▄▄▀█░▄█▀▄▀░░░░░
░░░░░█░░▀▄▄░░▀█░░░█░░▄▄▀▀▄▄█▀░░░░▀
░░░░▄▀░░░▀▄▀▀▄░▀▀▀▀▀▀▄▄▀▀▀▄▀░░░░▀
░░░▄▀░░░░░░▀▄░█▄▄▄▄▀▀░▀▄▀▀░░░▄▀▀
░░▄▀░░░░░░░░░▀▄▄▄▄█▄▄▀▀░░░░▄
░░█░░░░░░▀▄▄░░░▄▄▄▄▄▄▀░░░▄▀
░░█░░░░░░░░░▀▀▀▄▄▄▄▄▄▄▀▀
░░░█░░░░░░▀▀▀▀▀░░░░▄
░░░▀▀▄▄▄▄▄▄▄▄▄▀▀▀
Name:
Anonymous2013-11-30 6:25
*YOU HAVE BEEN VISITED BY LE TOP LEL OF COMEDY GOLD** POST THIS IN 3 threads or lose your sides!
░░░░░░░▄▀▀▀░▄▄▄▄░░░▀▀▀▀▀▀▀▀▄▄░▀
░░░░░░░█░░░░░░░░▀▀▀▀▀▄▄▄▄▄▄▄▄▀░░█
░░░░░▄▀░░░░░░░░░░▄░░░░░░░░▄▄░░░░░▀▄
░░░▄▀░░░░░▄▀▀▀█▄░▀░░░░▄▀▀▀██▀▀▄░░░░░▀
░░▄▀░░▄▄░░▀▀▀▀████▀░░░▀▄▄▀▀▀▀▄█░░░░░░█
░▄▀░▄▀█░░▄▄░░░░░░░█░░░░░▄▄▄░░░▀▀░░░░░░█
▄▀░░█░█░▀░░▀▀▄░░░░░█░░░░░░░▀▀▀▀▀▄░░░░░█
▀▄░░▀░█░░░▄░░░░░░▄▀░░░░▀▄░░░▄▄░░▀▄░█░▄▀
░░▀▄░░░░█▀▄░░░░░▀█░░░░▀▀░█▄▀▄░█░░░█░█
░░░░█░░█░▀▄▀▄▄░░░░▀▀▀░░░▄█▀░▄▀█░░░░▄
░░░░░█░░█░▀▀▄░▀▄▄▄▄▄▄▄▀█░▄█▀▄▀░░░░░
░░░░░█░░▀▄▄░░▀█░░░█░░▄▄▀▀▄▄█▀░░░░▀
░░░░▄▀░░░▀▄▀▀▄░▀▀▀▀▀▀▄▄▀▀▀▄▀░░░░▀
░░░▄▀░░░░░░▀▄░█▄▄▄▄▀▀░▀▄▀▀░░░▄▀▀
░░▄▀░░░░░░░░░▀▄▄▄▄█▄▄▀▀░░░░▄
░░█░░░░░░▀▄▄░░░▄▄▄▄▄▄▀░░░▄▀
░░█░░░░░░░░░▀▀▀▄▄▄▄▄▄▄▀▀
░░░█░░░░░░▀▀▀▀▀░░░░▄
░░░▀▀▄▄▄▄▄▄▄▄▄▀▀▀
Name:
Anonymous2013-11-30 6:28
*YOU HAVE BEEN VISITED BY LE TOP LEL OF COMEDY GOLD** POST THIS IN 3 threads or lose your sides!
░░░░░░░▄▀▀▀░▄▄▄▄░░░▀▀▀▀▀▀▀▀▄▄░▀
░░░░░░░█░░░░░░░░▀▀▀▀▀▄▄▄▄▄▄▄▄▀░░█
░░░░░▄▀░░░░░░░░░░▄░░░░░░░░▄▄░░░░░▀▄
░░░▄▀░░░░░▄▀▀▀█▄░▀░░░░▄▀▀▀██▀▀▄░░░░░▀
░░▄▀░░▄▄░░▀▀▀▀████▀░░░▀▄▄▀▀▀▀▄█░░░░░░█
░▄▀░▄▀█░░▄▄░░░░░░░█░░░░░▄▄▄░░░▀▀░░░░░░█
▄▀░░█░█░▀░░▀▀▄░░░░░█░░░░░░░▀▀▀▀▀▄░░░░░█
▀▄░░▀░█░░░▄░░░░░░▄▀░░░░▀▄░░░▄▄░░▀▄░█░▄▀
░░▀▄░░░░█▀▄░░░░░▀█░░░░▀▀░█▄▀▄░█░░░█░█
░░░░█░░█░▀▄▀▄▄░░░░▀▀▀░░░▄█▀░▄▀█░░░░▄
░░░░░█░░█░▀▀▄░▀▄▄▄▄▄▄▄▀█░▄█▀▄▀░░░░░
░░░░░█░░▀▄▄░░▀█░░░█░░▄▄▀▀▄▄█▀░░░░▀
░░░░▄▀░░░▀▄▀▀▄░▀▀▀▀▀▀▄▄▀▀▀▄▀░░░░▀
░░░▄▀░░░░░░▀▄░█▄▄▄▄▀▀░▀▄▀▀░░░▄▀▀
░░▄▀░░░░░░░░░▀▄▄▄▄█▄▄▀▀░░░░▄
░░█░░░░░░▀▄▄░░░▄▄▄▄▄▄▀░░░▄▀
░░█░░░░░░░░░▀▀▀▄▄▄▄▄▄▄▀▀
░░░█░░░░░░▀▀▀▀▀░░░░▄
░░░▀▀▄▄▄▄▄▄▄▄▄▀▀▀