# How to numbered title plot in looping?

1 view (last 30 days)
Eddy Iswardi on 24 Mar 2020
Commented: Eddy Iswardi on 26 Mar 2020
I want to make a numberd in my title plot. The number is following the looping. How to make it? this is my code
title('Grafik Perbandingan Orde %f',na)
and this is my full code
clc;
clear all;
xa=T.x;
ya=T.y;
x=transpose(xa);
y=transpose(ya);
n =length(x);
my=sum(y);
m = sum(bsxfun(@power,x(:),1:(2*n)),1);
myy = sum(bsxfun(@power,y(:),1:(2*n)),1);
xv = x(1:n);
yv = y(1:n);
ny = sum(bsxfun(@times,bsxfun(@power,xv(:),1:99),yv(:)),1);
for na=2:(n-1)
for i=1:na
for j=1:na
for k=1:na
A(1,1)=n;
if i>1
A(i,1)=m(i-1);
end
if k>1
A(i,k)=m(k-1);
if A(i,k)==A(i,k-1)
A(i,k)=m(k);
elseif A(i,k)<A(i,k-1)
A(i,k)=m(i+k-2);
end
end
end
end
end
B=[my 1];
for i=2:na
b = ny(i-1);
B(i)=b;
end
for k=1:na-1
for i=k+1:na
if A(i,k)~=0
lambda=A(i,k)/A(k,k);
for j=1:na
A(i,j)=A(i,j)-lambda*A(k,j);
end
B(i)=B(i)-lambda*B(k);
end
end
end
for i=na:-1:1
sumOut=0; % Replace sum with other variable
X(i)=0;
for j=1:na
sumOut=sumOut+A(i,j)*X(j);
end
X(i)=(B(i)-sumOut)/A(i,i);
end
for c = 1:n
R(c) = 0;
for d = 1:na
R(c) = R(c)+X(d)*x(c)^(d-1);
end
end
na;
R;
error=abs(y-R);
figure(na)
plot(1:length(y),y,1:length(R),R)
legend('Ymeasured','Prediksi')
title('Grafik Perbandingan Orde %f',na)
xlabel('Hari')
ylabel('Indeks Harga Saham')
hold on
t=0;
for s = 1:length(error)
t= t + error(s);
end
t;
ta(na)=t;
end
ta(1)=300;
ta;
xc=min(ta);
find(xc);
figure(100)
plot(ta)
title('Grafik Error')
xlabel('Orde Ke-')
ylabel('Nilai Error')
hold on

Robert U on 24 Mar 2020
Hi Eddy Iswardi,
The following minimal example show how to include numbers into axes titles:
for na = 1:3
fh{na} = figure;
ah{na} = axes(fh{na});
plot(ah{na},1:10,randn(1,10),'-black')
ah{na}.Title.String = sprintf('Grafik Perbandingan Orde %d',na);
end
In general, using handles for graphics objects makes life easier.
Kind regards,
Robert
Eddy Iswardi on 26 Mar 2020
thank you. it's work