Clear Filters
Clear Filters

Attempting to make multiple plots on multiple graphs using several arrays

1 view (last 30 days)
I'm trying to generate multiple plots using different columns from several matricies but at present I can only get one plot to show up with the plots on one diagram. I'm beginning to think I should have just used excel. Since I can't explain it much better than that, I've attached the code below.
% Xfoil polar. Reynolds number fixed. Mach  number fixed
% Polar key xf-naca651212-il-1000000
% Airfoil naca651212-il
% Reynolds number 1000000
% Ncrit 9
% Mach 0
% Max Cl/Cd 87.814
% Max Cl/Cd alpha 3.25
A = [
-9.5 -0.7923 0.02332 0.01914 -0.0473 0.9776 0.0123
-9.25 -0.7622 0.02202 0.01763 -0.0489 0.9698 0.0126
-9 -0.7351 0.02123 0.01666 -0.0495 0.9585 0.0129
-8.75 -0.72 0.0179 0.01298 -0.0484 0.9453 0.0135
-8.25 -0.6762 0.01677 0.01171 -0.047 0.9234 0.0143
-8 -0.654 0.01619 0.01103 -0.0462 0.9138 0.0147
-6.25 -0.4926 0.01183 0.00608 -0.0419 0.856 0.0184
-6 -0.4675 0.01151 0.00573 -0.0416 0.8488 0.0192
-5.75 -0.4421 0.01121 0.00538 -0.0413 0.8414 0.0201
-5.5 -0.4168 0.01087 0.00498 -0.041 0.8346 0.0209
-5 -0.365 0.01032 0.00433 -0.0406 0.8214 0.0221
-4.75 -0.3409 0.00969 0.00362 -0.0402 0.8145 0.0237
-4.25 -0.2878 0.00921 0.00307 -0.04 0.8017 0.0273
-4 -0.2607 0.00905 0.00287 -0.04 0.7954 0.0288
-3.75 -0.2342 0.00873 0.0025 -0.0399 0.7897 0.0328
-3.5 -0.2069 0.00853 0.00229 -0.0399 0.7835 0.0368
-3 -0.1553 0.00759 0.00178 -0.0398 0.7718 0.1581
-2.75 -0.1333 0.00642 0.00139 -0.0397 0.766 0.377
-2.5 -0.1088 0.0057 0.00121 -0.0396 0.7607 0.5377
-2.25 -0.0811 0.00555 0.00117 -0.0397 0.7551 0.5827
-1.75 -0.0246 0.00545 0.00113 -0.04 0.7446 0.6322
-1.5 0.0035 0.00541 0.00114 -0.0401 0.7393 0.6549
-1.25 0.0317 0.00543 0.00115 -0.0402 0.7342 0.6728
-0.75 0.0888 0.00543 0.00118 -0.0406 0.7242 0.6958
-0.5 0.1173 0.00545 0.00117 -0.0408 0.7194 0.7007
-0.25 0.1463 0.00546 0.00117 -0.0411 0.7147 0.7056
0 0.175 0.00545 0.00117 -0.0413 0.7099 0.7103
0.25 0.2035 0.00547 0.00118 -0.0415 0.7052 0.7153
0.5 0.2324 0.00549 0.00119 -0.0418 0.7008 0.7203
0.75 0.2611 0.00549 0.00121 -0.042 0.6961 0.7252
1 0.2896 0.00551 0.00125 -0.0422 0.6915 0.7303
1.25 0.3183 0.00554 0.00128 -0.0425 0.6859 0.7357
1.5 0.3466 0.00554 0.00129 -0.0426 0.6778 0.7408
1.75 0.3747 0.00555 0.00132 -0.0427 0.6669 0.7462
2 0.4029 0.0056 0.00134 -0.0428 0.6541 0.7518
2.25 0.4303 0.00563 0.00136 -0.0428 0.6352 0.7572
2.5 0.4579 0.00569 0.0014 -0.0428 0.6183 0.7631
2.75 0.4853 0.00579 0.00146 -0.0428 0.5958 0.7688
3.25 0.5383 0.00613 0.00163 -0.0424 0.5275 0.7808
3.5 0.5587 0.00686 0.00191 -0.0414 0.4079 0.787
3.75 0.5746 0.00812 0.00245 -0.0398 0.2379 0.794
4 0.5927 0.00915 0.00293 -0.0386 0.1086 0.8005
4.25 0.6139 0.00984 0.00333 -0.0377 0.044 0.8075
4.5 0.6387 0.01019 0.00365 -0.0373 0.0327 0.8144
4.75 0.6643 0.01041 0.00392 -0.037 0.0298 0.8215
5 0.6882 0.01083 0.00436 -0.0364 0.0252 0.8289
5.25 0.7135 0.01104 0.00462 -0.0361 0.0238 0.8361
5.5 0.7384 0.01132 0.00494 -0.0357 0.0223 0.8437
6 0.7827 0.01229 0.00602 -0.034 0.0192 0.8601
6.25 0.8056 0.01265 0.00646 -0.0332 0.0186 0.869
6.5 0.8283 0.01301 0.00688 -0.0324 0.0181 0.8778
7 0.8713 0.01383 0.00784 -0.0304 0.0169 0.8974
7.25 0.8926 0.01418 0.00823 -0.0294 0.0162 0.9081
7.5 0.9126 0.01457 0.00867 -0.0282 0.0156 0.92
8 0.9368 0.01648 0.01079 -0.023 0.0144 0.9571
8.25 0.9635 0.0172 0.01161 -0.0234 0.0142 1
8.5 0.9857 0.01781 0.01227 -0.0229 0.014 1
8.75 1.0069 0.01856 0.01308 -0.0221 0.0137 1];
% Xfoil polar. Reynolds number fixed. Mach  number fixed
% Polar key xf-naca651212-il-1000000-n5
% Airfoil naca651212-il
% Reynolds number 1000000
% Ncrit 5
% Mach 0
% Max Cl/Cd 70.796
% Max Cl/Cd alpha 2.25
B = [-9.5 -0.8157 0.01598 0.01068 -0.0444 0.894 0.0104
-9.25 -0.7935 0.01554 0.01016 -0.0437 0.8849 0.0107
-9 -0.7709 0.01515 0.00969 -0.0431 0.8757 0.011
-8.75 -0.7482 0.01468 0.00913 -0.0426 0.867 0.0113
-8.25 -0.7009 0.01394 0.00824 -0.0417 0.851 0.012
-8 -0.6774 0.01354 0.00774 -0.0412 0.8435 0.0122
-6.25 -0.5049 0.01097 0.00478 -0.039 0.7947 0.0149
-6 -0.479 0.0107 0.00445 -0.0389 0.788 0.0153
-5.75 -0.4529 0.01044 0.00414 -0.0387 0.7822 0.0159
-5.5 -0.4264 0.01021 0.00386 -0.0387 0.7761 0.0162
-5 -0.3736 0.00969 0.00327 -0.0385 0.7644 0.0182
-4.75 -0.3468 0.00949 0.00305 -0.0385 0.7582 0.0192
-4.25 -0.2924 0.00916 0.00265 -0.0386 0.747 0.0214
-4 -0.2652 0.00899 0.00245 -0.0386 0.7417 0.023
-3.75 -0.2378 0.00881 0.00227 -0.0387 0.7368 0.0256
-3.5 -0.2102 0.00867 0.00212 -0.0388 0.7313 0.0279
-3 -0.155 0.0084 0.00183 -0.039 0.7211 0.0374
-2.75 -0.1276 0.00819 0.0017 -0.0391 0.7162 0.0572
-2.5 -0.1007 0.0079 0.00154 -0.0392 0.7113 0.1037
-2.25 -0.0748 0.00739 0.00135 -0.0393 0.7068 0.2001
-1.75 -0.025 0.00589 0.00093 -0.0395 0.6971 0.515
-1.5 0.0024 0.00567 0.00091 -0.0396 0.6929 0.5813
-1.25 0.0305 0.00557 0.00091 -0.0397 0.6882 0.6158
-0.75 0.0873 0.00553 0.00091 -0.0401 0.6792 0.6504
-0.5 0.1161 0.00552 0.00091 -0.0404 0.6749 0.6569
-0.25 0.1449 0.00552 0.00091 -0.0406 0.6703 0.6616
0 0.1736 0.00555 0.00091 -0.0409 0.666 0.6661
0.25 0.2024 0.00555 0.00092 -0.0411 0.6619 0.6704
0.5 0.2312 0.00555 0.00094 -0.0414 0.6575 0.6751
0.75 0.2599 0.00558 0.00095 -0.0416 0.653 0.6798
1 0.2885 0.0056 0.00098 -0.0419 0.6489 0.6842
1.25 0.3171 0.00561 0.00102 -0.0421 0.642 0.6888
1.5 0.3452 0.00567 0.00104 -0.0422 0.6276 0.6938
1.75 0.3733 0.00573 0.00108 -0.0423 0.6137 0.6983
2 0.4006 0.00583 0.00112 -0.0423 0.5912 0.703
2.25 0.4269 0.00603 0.00118 -0.0421 0.5476 0.7082
2.5 0.4517 0.0064 0.00131 -0.0418 0.4799 0.7131
2.75 0.4715 0.00729 0.00165 -0.0407 0.343 0.7182
3.25 0.5145 0.00879 0.00232 -0.0393 0.1363 0.7285
3.5 0.5377 0.00933 0.00262 -0.0388 0.0721 0.7341
3.75 0.5626 0.00969 0.00286 -0.0385 0.0411 0.74
4 0.5888 0.00992 0.00306 -0.0383 0.0321 0.7453
4.25 0.615 0.01012 0.00326 -0.0382 0.028 0.7511
4.5 0.6413 0.01033 0.00348 -0.038 0.0246 0.7569
4.75 0.6675 0.01051 0.00369 -0.0379 0.0227 0.7628
5 0.6933 0.01074 0.00393 -0.0377 0.0205 0.7695
5.25 0.7187 0.01099 0.00421 -0.0374 0.0184 0.7757
5.5 0.7444 0.01121 0.00447 -0.0372 0.0175 0.7824
6 0.7946 0.01172 0.00502 -0.0366 0.0152 0.7953
6.25 0.8186 0.01208 0.00541 -0.0361 0.014 0.8025
6.5 0.843 0.01235 0.00574 -0.0357 0.0137 0.8097
7 0.8907 0.01298 0.00648 -0.0347 0.0129 0.8247
7.25 0.914 0.01333 0.00689 -0.0341 0.0125 0.8324
7.5 0.9367 0.01369 0.0073 -0.0334 0.0122 0.8403
8 0.9808 0.01444 0.00817 -0.0318 0.0116 0.8582
8.25 1.0019 0.01486 0.00865 -0.0309 0.0114 0.8675
8.5 1.0221 0.01532 0.00917 -0.0298 0.011 0.8776
8.75 1.0407 0.01583 0.00976 -0.0285 0.0108 0.889];
s = 'AB';
for ns = 1:length(s)
Dan = eval(s(ns));
subplot(3,2,1)
plot(Dan(:,1),Dan(:,2)); % Cl vs Alpha
hold on
title('Cl vs Alpha');
xlabel('Angle of Attack'); % x-axis label
ylabel('Cl') % y-axis label
DivA = bsxfun(@rdivide,Dan(:,2),(Dan(:,3))); % dividing colum 2 by 3 (cl/cd)
subplot(3,2,2)
plot(Dan(:,1),DivA) % Cl / Cd vs Alpha
title('Cl / Cd vs Alpha')
subplot(3,2,3)
plot(Dan(:,1),Dan(:,3)) % Cd vs Alpha
title('Cd vs Alpha')
subplot(3,2,4)
plot(Dan(:,1),Dan(:,5)) % Cm vs Alpha
title('Cm vs Alpha')
subplot(3,2,5)
%subplot(Dan(:,3),Dan(:,2)) % Cl vs Cd
%title('Cl vs Cd')
end
  1 Comment
Aletta Wilbrink
Aletta Wilbrink on 9 Apr 2018
When I run your code, I do get to see multiple plots. What is it exactly you want?
Do you want multiple figures? Or do you want all the plots in the same window?

Sign in to comment.

Answers (2)

Daniel Jones
Daniel Jones on 9 Apr 2018
I changed it so that there should only be two lines per plot. Currently I only get the two lines for the first plot the remaining plots have just the one line.

Aletta Wilbrink
Aletta Wilbrink on 10 Apr 2018
Every time you want a new line in the same plot use hold on and if you want a new plot use hold off.
You only use hold on for the first plot now

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!