Plotting between 2 points in 2017b

10 ビュー (過去 30 日間)
Kelb77
Kelb77 2017 年 11 月 6 日
コメント済み: Kelb77 2017 年 11 月 6 日
clear all; close all force; clc;
% inputs
AR=5;
L=.5;
Swp_25=45;
%Calcs
b=1; % unit length here
Cr=(2*b)/(AR*(L+1));
Ct=L*Cr;
S=((Cr+Ct)/2)*b;
Swp_LE=atand(tand(Swp_25)+(4/AR)*(.25*((1-L)/(1+L))));
xpc=[0,.25,.50,.75,1.00];
% [Swp0,Swp25,Swp50,Swp75,Swp100]
Swp=atand(tand(Swp_LE)-(4/AR)*(xpc.*((1-L)/(1+L))));
qc=.25*Cr;%length of quarter chord
y11=0;
y12=.125*b;%1/8 of total wingspan
y21=y12;
y22=.25*b;%1/4 of total wingspan
y31=y22;
y32=.375*b;%3/8 of total wingspan
y41=y32;
y42=.5*b;% 1/2 of total wingspan
x11=qc;
x12=x11+y12*tand(Swp(2))*b;
x21=x12;
x22=x11+y22*tand(Swp(2))*b;
x31=x22;
x32=x11+y32*tand(Swp(2))*b;
x41=x32;
x42=x11+y42*tand(Swp(2))*b;
y1m=(y11+y12)/2;
y2m=(y21+y22)/2;
y3m=(y31+y32)/2;
y4m=(y41+y42)/2;
x75=qc*3;%x at 3/4 of root chord
x1m=x75+y1m*tand(Swp(4))*b;
x2m=x75+y2m*tand(Swp(4))*b;
x3m=x75+y3m*tand(Swp(4))*b;
x4m=x75+y4m*tand(Swp(4))*b;
%table
f=uifigure;
headers={'Panel','Xm','Ym','X1n','Y1n','X2n','Y2n'};
data=[1 x1m y1m x11 y11 x12 y21
2 x2m y2m x21 y21 x22 y22
3 x3m y3m x31 y31 x32 y32
4 x4m y4m x41 y41 x42 y42];
t=uitable(f,'Data',data,'ColumnName',headers);
%plot
y=0:.01:y42;
xLE=y.*tand(Swp(1));
xTE=Cr+y.*tand(Swp(5));
xle=xLE(end);
xte=xTE(end);
plot(xLE,y)
hold on
plot(xTE,y)
plot([Cr 0], [0 0])
TC1=[xle,y42];
TC2=[xte,y42]; % my issue is right here
plot(xle,y42,'x') % this works
plot(xte,y42,'x') % this works
plot(TC1,TC2) % this does not work, plots line in wrong place
plot(x1m,y1m,'*')
plot(x2m,y2m,'*')
plot(x3m,y3m,'*')
plot(x4m,y4m,'*')
plot(x11,y11,'o')
plot(x21,y21,'o')
plot(x31,y31,'o')
plot(x41,y41,'o')
legend('Leading Edge','Trailing Edge','Root Chord','Tip Chord','CP1','CP2','CP3','CP4')
legend('Location','northwest')
I'm having some kind of problem with plotting one of my line segments. I can plot both end points of my line but when I try and plot the line between them it's in the wrong place. I'm so confused

採用された回答

Cam Salzberger
Cam Salzberger 2017 年 11 月 6 日
Assuming your variable names are reasonable, TC1 and TC2 are both a 1x2 array containing x-data for the first element and y-data for the second element. So you are calling:
plot([x1 y1], [x2 y2])
But plot requires the first argument to be all the x-data, and the second argument to be all the y-data:
plot([x1 x2], [y1 y2])
So you have to rearrange how you make that call:
plot([TC1(1) TC2(1)], [TC1(2) TC2(2)])
-Cam
  1 件のコメント
Kelb77
Kelb77 2017 年 11 月 6 日
THANK YOU

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by