How to reduce this code to one line.

2 Ansichten (letzte 30 Tage)
Christopher
Christopher am 20 Jul. 2013
Hello, I am trying to reduce the number of lines in my code and was wondering if there is an easy way to do this. Given below are my inputs and my actual code. I don't need to reduce any of the inputs, just the actual code itself. Ideally, I would like to reduce S1 and E1 to one line each. Thank you
%%%%Inputs %%%%
npan1=25; % number of panels patch 1
A=[0 -5 0];
B=[0 0 0];
npan2=25; % number of panels patch 1
A1=[0 0 0];
B1=[0 5 0];
%%%%Code %%%%
nlatall=npan1+npan2;
ss1=bsxfun(@times,B+(A-B),[1:npan1]'/npan1);
ss2=bsxfun(@times,A1+(B1-A1),[0:npan2-1]'/npan2);
e1=flipud(ss2);
S1=flipud([e1;ss1]);
ee1=bsxfun(@times,B+(A-B),[0:npan1-1]'/npan1);
ee2=bsxfun(@times,A1+(B1-A1),[1:npan2]'/npan2);
gg=flipud(ee2);
E1=flipud([gg;ee1]);
  1 Kommentar
the cyclist
the cyclist am 20 Jul. 2013
Is this a class assignment? What makes you believe that this code can be reduced?
Maybe you could describe, conceptually, what each line of code does.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by