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 10:25

>>11
PERL:
''=~(        '(?{'        .('`'        |'%')        .('['        ^'-')
    .('`'        |'!')        .('`'        |',')        .'"'.        '\\$'
    .'=='        .('['        ^'+')        .('`'        |'/')        .('['
    ^'+')        .'||'        .(';'        &'=')        .(';'        &'=')
    .';-'        .'-'.        '\\$'        .'=;'        .('['        ^'(')
    .('['        ^'.')        .('`'        |'"')        .('!'        ^'+')
   .'_\\{'      .'(\\$'      .';=('.      '\\$=|'      ."\|".(      '`'^'.'
  ).(('`')|    '/').').'    .'\\"'.+(    '{'^'[').    ('`'|'"')    .('`'|'/'
 ).('['^'/')  .('['^'/').  ('`'|',').(  '`'|('%')).  '\\".\\"'.(  '['^('(')).
 '\\"'.('['^  '#').'!!--'  .'\\$=.\\"'  .('{'^'[').  ('`'|'/').(  '`'|"\&").(
 '{'^"\[").(  '`'|"\"").(  '`'|"\%").(  '`'|"\%").(  '['^(')')).  '\\").\\"'.
 ('{'^'[').(  '`'|"\/").(  '`'|"\.").(  '{'^"\[").(  '['^"\/").(  '`'|"\(").(
 '`'|"\%").(  '{'^"\[").(  '['^"\,").(  '`'|"\!").(  '`'|"\,").(  '`'|(',')).
 '\\"\\}'.+(  '['^"\+").(  '['^"\)").(  '`'|"\)").(  '`'|"\.").(  '['^('/')).
 '+_,\\",'.(  '{'^('[')).  ('\\$;!').(  '!'^"\+").(  '{'^"\/").(  '`'|"\!").(
 '`'|"\+").(  '`'|"\%").(  '{'^"\[").(  '`'|"\/").(  '`'|"\.").(  '`'|"\%").(
 '{'^"\[").(  '`'|"\$").(  '`'|"\/").(  '['^"\,").(  '`'|('.')).  ','.(('{')^
 '[').("\["^  '+').("\`"|  '!').("\["^  '(').("\["^  '(').("\{"^  '[').("\`"|
 ')').("\["^  '/').("\{"^  '[').("\`"|  '!').("\["^  ')').("\`"|  '/').("\["^
 '.').("\`"|  '.').("\`"|  '$')."\,".(  '!'^('+')).  '\\",_,\\"'  .'!'.("\!"^
 '+').("\!"^  '+').'\\"'.  ('['^',').(  '`'|"\(").(  '`'|"\)").(  '`'|"\,").(
 '`'|('%')).  '++\\$="})'  );$:=('.')^  '~';$~='@'|  '(';$^=')'^  '[';$/='`';

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