Advertisement
Guest User

matlab

a guest
Apr 25th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 2.49 KB | None | 0 0
  1. config='Cruise';
  2. addpath('Helpers')
  3.  
  4. clear all
  5. clc
  6. close all
  7.  
  8. %Cruise
  9. CLc=[1.8884 0.01017 -1.7652];
  10. CDc=[0.1403 -0.04123    0.1353];
  11.  
  12. %Cruise, trimmed
  13. CLct=[1.73999   0.01009 -1.6175];
  14. CDct=[0.1169    -0.02943    0.1120];
  15.  
  16. %Flaps TO
  17. CLto_min = -0.8361 - (1.835 - -0.8361);
  18. CLto=[1.835 -0.8361 CLto_min];
  19. CDto=[0.11714   0.08347 0.11714];
  20.  
  21. %Flaps Landing
  22. CLl_min = -0.663 - (1.89016 - -0.663);
  23. CLl=[1.89016    -0.663  CLl_min];
  24. CDl=[0.13151    0.04126 0.13151];
  25.  
  26. %Calculate polars
  27. xc = [CLc(1) CLc(2) CLc(3)];                % Define Points
  28. yc = [CDc(1) CDc(2) CDc(3)];
  29. xmc = @(xc) [xc'.^2  xc'  ones(size(xc))'];  % Quadratic Regression Matrix
  30. bc = xmc(xc)\yc';                           % Estimate Parameters
  31. xo = linspace(min(xc)-1,max(xc)+1);       % Create X-Value Vector
  32. yo = xmc(xo)*bc;                          % Calculate Y-Values
  33.  
  34. xct = [CLct(1) CLct(2) CLct(3)];                % Define Points
  35. yct = [CDct(1) CDct(2) CDct(3)];
  36. xmct = @(xct) [xct'.^2  xct'  ones(size(xct))'];  % Quadratic Regression Matrix
  37. bct = xmct(xct)\yct';                           % Estimate Parameters
  38. xoct = linspace(min(xct)-1,max(xct)+1);       % Create X-Value Vector
  39. yoct = xmct(xoct)*bct;                          % Calculate Y-Values
  40.  
  41. xto = [CLto(1) CLto(2) CLto(3)];                % Define Points
  42. yto = [CDto(1) CDto(2) CDto(3)];
  43. xmto = @(xto) [xto'.^2  xto'  ones(size(xto))'];  % Quadratic Regression Matrix
  44. bto = xmto(xto)\yto';                           % Estimate Parameters
  45. xoto = linspace(min(xto)-1,max(xto)+1);       % Create X-Value Vector
  46. yoto = xmto(xoto)*bto;                          % Calculate Y-Values
  47.  
  48. xl = [CLl(1) CLl(2) CLl(3)];                % Define Points
  49. yl = [CDl(1) CDl(2) CDl(3)];
  50. xml = @(xl) [xl'.^2  xl'  ones(size(xl))'];  % Quadratic Regression Matrix
  51. bl = xml(xl)\yl';                           % Estimate Parameters
  52. xol = linspace(min(xl)-1,max(xl)+1);       % Create X-Value Vector
  53. yol = xml(xol)*bl;                          % Calculate Y-Values
  54.  
  55. disp('Remember the latexPlot functions')
  56.  
  57. %Plots
  58. figure(1)
  59. plot(yo,xo,'-b',yc,xc,'pb')
  60. hold on
  61. plot(yoct,xoct,'-r',yct,xct,'pr')
  62. xlabel('Drag Coefficient (CD)');ylabel('Lift Coefficient (CL)');
  63. legend('Cruise','Max and Min Limits','Trimmed Cruise','Max and Min Limits')
  64.  
  65. figure(2)
  66. plot(yoto,xoto,'-m',yto,xto,'pm')
  67. hold on
  68. plot(yol,xol,'-c',yl,xl,'pc')
  69. xlabel('Drag Coefficient (CD)');ylabel('Lift Coefficient (CL)');
  70. legend('Take Off','Max and Min Limits','Landing','Max and Min Limits')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement