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: Laur 2013-01-25 16:21

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

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