Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Oh MATLAB

Name: Laur 2013-01-25 4:32

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: Anonymous 2013-01-25 16:28

>>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.

Fuck off back to Facebook with your emoticons.

Please learn to space your paragraphs.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List