MATLAB: Data curve fitting, connecting point

connecting data pointscurve fitting

Hi everyone, I have this code for sizing and it's similar to a carpet plot
%%Take-Off distance sizing
clear all; close all; clc;
% Specify value for Variables: s_TO = 1000; % take off distance in feet s_GTO = s_TO/1.66; % ground roll take off distance in ft sigma = 1; % density ratio
% enter range for max lift coefficient for Take-Off C_LmaxTO_begin = 1.2; C_LmaxTO_end = 1.8; L1 = C_LmaxTO_end – C_LmaxTO_begin;
% enter range for wing loading W_S_begin = 10; W_S_end = 60; L2 = W_S_end-W_S_begin;
n = 10; % incerement size
d1 = L1/(n-1); d2 = L2/(n-1);
C_LmaxTO = C_LmaxTO_begin:d1:C_LmaxTO_end; W_S = W_S_begin:d2:W_S_end;
% Solve: TOP = 300;
for i = 1:length(C_LmaxTO) for j = 1:length(W_S) W_P(i,j) = TOP*sigma*C_LmaxTO(i)/W_S(j); end end
[X1,Y1] = meshgrid(W_S,W_P);
figure(),hold on for i = 1:length(C_LmaxTO) plot(W_S(i),W_P(:,i),'.-') end
I don't necessarily want a curve fitting but I want the dots to connect. I tried adding '.-' to the plot but it doesn't seem to work. Is there a simple way for that or I have to apply a curve fitting ? Thank you in advance.

Best Answer

Karim,
lose the for loop and just issue the plot command as shown below
clear; close all; clc;
% Specify value for Variables:
s_TO = 1000; % take off distance in feet
s_GTO = s_TO/1.66; % ground roll take off distance in ft
sigma = 1; % density ratio
% enter range for max lift coefficient for Take-Off
C_LmaxTO_begin = 1.2;
C_LmaxTO_end = 1.8;
L1 = C_LmaxTO_end - C_LmaxTO_begin;
% enter range for wing loading
W_S_begin = 10;
W_S_end = 60;
L2 = W_S_end-W_S_begin;
n = 10; % incerement size
d1 = L1/(n-1);
d2 = L2/(n-1);
C_LmaxTO = C_LmaxTO_begin:d1:C_LmaxTO_end;
W_S = W_S_begin:d2:W_S_end;
% Solve:
TOP = 300;
for i = 1:length(C_LmaxTO)
for j = 1:length(W_S)
W_P(i,j) = TOP*sigma*C_LmaxTO(i)/W_S(j);
end
end
[X1,Y1] = meshgrid(W_S,W_P);
plot(W_S,W_P(:,1:10)','.-') %changes made here