How can put the numbers in line eqution?

조회 수: 1 (최근 30일)
MOzhdeh Salimi
MOzhdeh Salimi 2021년 9월 3일
댓글: Sulaymon Eshkabilov 2021년 9월 3일
Hi
This is my code. I want put ('X') data in line equation ('p'). After run ('polyfit') code, just I could see the two numbers that refer to coefficients. now I want to put the series of numbers in the line regression equation ('p').
please help me.
Thanks.
VF = imread('Vf.tif');
Tnormal= imread('Tnormmsh.tif');
[i,j]=size(VF);
length=i*j;
X=VF(1:length);
Y=Tnormal(1:length);
Minx=min(X);
Maxx=max(X);
Miny=min(Y);
Maxy=max(Y);
x0=Minx:0.01:Maxx;
Tmax=zeros(size(x0));
for i = 1:1:numel(x0)
x1 = x0(i);
X1=x1;
X2=x1+0.01;
idx= find(X>=X1 & X<X2);
x3=X(idx);
y3=Y(idx);
Tmax(i)=max(y3) ;
end
p=polyfit(x0,Tmax,1);

채택된 답변

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 9월 3일
There are a few points can be fixed and improved in your code, e.g.:
...
X=double(VF(1:length)); % Conversion to double() needed
Y=double(Tnormal(1:length)); % Conversion to double() needed
...
p=polyfit(x0,Tmax,1);
Pval=polyval(p, X); % The values of Fit model computed
  댓글 수: 2
MOzhdeh Salimi
MOzhdeh Salimi 2021년 9월 3일
Thank you so much.
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 9월 3일
Most welcome!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by