Can someone help me with my code?

2 次查看(过去 30 天)
clear all, clc, close all;
N=1:99;
alfa=0.05;
z=1.96;
t= 1.984; %two-tailed t critical for 95% confidence interval
N_l=(4.459595959595959e+03+4.419191919191920e+03)/2; %population lower mean
N_u=(5.833333333333333e+03+6.080808080808080e+03)/2; %population upper mean
Sample_l=[];
Sample_u=[];
gpa=[2.25,2.75,2.75,2.75,2.75,2.75,2.75,2.75,3.25,3.75,3.75,2.25,2.25,2.25,2.25,2.25,2.75,2.75,2.75,2.75,2.25,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,3.25,3.25,3.25,3.25,3.25,3.25,3.25,3.25,3.75,2.25,2.25,2.25,2.25,2.75,2.75,2.75,2.75,3.25,3.25,3.25,3.25,3.25,3.25,3.25,3.25,2.25,2.25,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,3.25,3.25,3.25,3.25,3.25,3.25,3.75,3.75,2.25,2.25,2.25,2.25,2.25,2.25,2.25,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,3.25,3.25,3.25,3.25,3.25,3.25,3.25,3.25,3.25,3.25,3.25,3.75];
for i=1:11
Sample_l(i)=2500;
Sample_u(i)=3500;
end;
for j=12:20
Sample_l(j)=3500;
Sample_u(j)=4000;
end;
for k=21:38
Sample_l(k)=4000;
Sample_u(k)=4500;
end;
for t=39:54
Sample_l(t)=4500;
Sample_u(t)=5000;
end;
for z=55:72
Sample_l(z)=5000;
Sample_u(z)=5500;
end;
for u=73:99
Sample_l(u)=5500;
Sample_u(u)=9000;
end;
A=sum(Sample_l)/99; %mean of the lower limit
B=sum(Sample_u)/99; %mean of the upper limit
Var_l=var(Sample_l); %var of the lower limit
Var_u=var(Sample_u); %var of the upper limit
Std_l=std(Sample_l); %Standart deviation of the lower limit
Std_u=std(Sample_u); %Standart deviation of the upper limit
Hello everyone, I am trying to find linear regration between "gpa" and "Sample_l" but I could not do it in matlab. Actually I could not understand how to do it. Is there anyone who can help me?
Thanks a lot!

回答(1 个)

Cris LaPierre
Cris LaPierre 2020-12-20
There are a couple ways to do this in MATLAB. I'll go with the one that doesn't require any additional toolboxes.
You can do this with polyfit, which tries to fit a polynomial of a specified order to the X and Y data. Linear regression is just fitting a polynomial of first order ().
You can follow this example.

类别

Help CenterFile Exchange 中查找有关 Descriptive Statistics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by