Category: Matlab
Category Archives: Matlab
Auto detecting multiple points and tracking their locations
I have a binary video with a few hundred moving white dots that I would like to track and get their respective x and y location individually. I tried following this example: https://www.mathworks.com/help/vision/ug/motion-based-multiple-object-tracking.html to auto track the points but it seems like the the white dots are too small or too dense to be picked up. Anyone have any advice?I have a binary video with a few hundred moving white dots that I would like to track and get their respective x and y location individually. I tried following this example: https://www.mathworks.com/help/vision/ug/motion-based-multiple-object-tracking.html to auto track the points but it seems like the the white dots are too small or too dense to be picked up. Anyone have any advice? I have a binary video with a few hundred moving white dots that I would like to track and get their respective x and y location individually. I tried following this example: https://www.mathworks.com/help/vision/ug/motion-based-multiple-object-tracking.html to auto track the points but it seems like the the white dots are too small or too dense to be picked up. Anyone have any advice? computer vision, binary image, video, tracking MATLAB Answers — New Questions
Why my matlab can’t show and save images?
clear all;
clc
%————————Menentukan Parameter—————%
L=2000; % panjang kanal(m)
T=3600; % lama simulasi (s)
dx=20; % lebar grid (m)
ln=0:dx:L;
y=length(ln); % panjang grid
n=L/dx; % jumlah grid
dt=2;
t=0:dt:T;
var=length(t); % panjang waktu
u1=-0.245;
u2=0.215;
pc=75; % polutan kontinu
pdc=100; % polutan diskontinu
%—————–Menentukan Domain——————-%
%skenario 1 (u1 polutan kontinu)
kk1=zeros(var,y); % nilai awal
kk1(:,15)=pc; % nilai konsentrasi polutan kontinu
%skenario 2 (u2 polutan kontinu)
kk2=zeros(var,y); % nilai awal
kk2(:,15)=pc; % nilai konsentrasi polutan kontinu
%skenario 3 (u1 polutan diskontinu)
kd1=zeros(var,y); % nilai awal
kd1(19,11)=pdc; % nilai konsentrasi polutan kontinu
%skenario 4 (u2 polutan diskontinu)
kd2=zeros(var,y); % nilai awal
kd2(19,11)=pdc; % nilai konsentrasi polutan kontinu
%—————-Perhitungan Upstream—————%
%%—skenario 1 dan 3 (untuk polutan u1)—–%%
lam1=(dt/(2*dx)); % konstanta untk numerik untuk polutan u1
if(-1<=lam1<=1); % syarat perhitungan upstream
disp(‘Model Jalan’);
else
return
end
%%% u1 kontinu
for np=1:var-1; % looping waktu
for i=2:y-1; % looping ruang
a=u1-abs(u1);
b=kk1(np,i+1)-kk1(np,i);
c=u1+abs(u1);
d=kk1(np,i)-kk1(np,i-1);
kk1(np+1,i)=kk1(np,i)-lam1*((a*b)+(c*d));
end;
kk1(:,15)=pc;
kk1(np,1)=kk1(np,2); %nilai batas kiri
kk1(np,y)=kk1(np,y-1); %niai batas kanan
end;
%%% u1 diskontinu
for np=1:var-1; % looping waktu
for i=2:y-1; % looping ruang
a=u1-abs(u1);
b=kd1(np,i+1)-kd1(np,i);
c=u1+abs(u1);
d=kd1(np,i)-kd1(np,i-1);
kd1(np+1,i)=kd1(np,i)-lam1*((a*b)+(c*d));
end;
kd1(19,11)=pc;
kd1(np,1)=kd1(np,2);
kd1(np,y)=kd1(np,y-1);
end;
%%———–skenario 2 dan 4 (untuk polutan u2)————-%
%%% u2 kontinu
for np=1:var-1; % looping waktu
for i=2:y-1; % looping ruang
a=u2-abs(u2);
b=kk2(np,i+1)-kk2(np,i);
c=u2+abs(u2);
d=kk2(np,i)-kk2(np,i-1);
kk2(np+1,i)=kk2(np,i)-lam1*((a*b)+(c*d));
end;
kk2(:,15)=pc;
kk2(np,1)=kk2(np,2);
kk2(np,y)=kk2(np,y-1);
end;
%% u2 diskontinu
for np=1:var-1; % looping waktu
for i=2:y-1; % looping ruang
a=u2-abs(u2);
b=kd2(np,i+1)-kd2(np,i);
c=u2+abs(u2);
d=kd2(np,i)-kd2(np,i-1);
kd2(np+1,i)=kd2(np,i)-lam1*((a*b)+(c*d));
end;
kd2(19,11)=pc;
kd2(np,1)=kd2(np,2);
kd2(np,y)=kd2(np,y-1);
end;
%—————ploting——————–%
timev=[300 600 900 1200 1500];
tiv=[5 25 50 75 100];
%ploting u1 kontinu
figure(17);
plot(t,kk1(:,tiv(1)),t,kk1(:,tiv(2)),t,kk1(:,tiv(3)),t,kk1(:,tiv(4)),t,kk1(:,tiv(5)));
xlabel(‘waktu (s)’);ylabel(‘konsentrasi’);
legend(‘100 m’,’500 m’,’1000 m’,’1500 m’,’2000 m’);
title(‘Grafik Perubahan Konsentrasi Terhadap waktu untuk u1 polutan kontinu dengan metode Upstream’);
set(17,’Position’,get(0,’Screensize’));
saveas(17,’Grafik Perubahan Konsentrasi terhadap Waktu untuk u1 Polutan Kontinu dengan Metode Upstream.jpg’);
figure (18);
plot(ln,kk1(timev(1),:),ln,kk1(timev(2),:),ln,kk1(timev(3),:),ln,kk1(timev(4),:),ln,kk1(timev(5),:)),
xlabel(‘Kanal’);ylabel(‘Konsentrasi’);
legend(‘600 s’,’1200 s’,’1800 s’,’2400 s’,’3000 s’);
title(‘Grafik Perubahan Konsentrasi Terhadap Ruang untuk u1 Polutan Kontinu dengan Metode Upstream’);
set(18,’Position’,get(0,’Screensize’));
saveas(18,’Grafik Perubahan Konsentrasi terhadap ruang untuk u1 Polutan Kontinu dengan Metode Upstream.jpg’);
%%Ploting u2 kontinu
figure(19);
plot(t,kk2(:,tiv(1)),t,kk2(:,tiv(2)),t,kk2(:,tiv(3)),t,kk2(:,tiv(4)),t,kk2(:,tiv(5)));
xlabel(‘waktu (s)’);ylabel(‘konsentrasi’);
legend(‘100 m’,’500 m’,’1000 m’,’1500 m’,’2000 m’);
title(‘Grafik Perubahan Konsentrasi Terhadap waktu untuk u2 Polutan Kontinu dengan Metode Upstream’);
set(19,’Position’,get(0,’Screensize’));
saveas(19,’Grafik Perubahan Konsentrasi terhadap Waktu untuk u2 Polutan Kontinu dengan Metode Upstream.jpg’);
figure(20);
plot(ln,kk2(timev(1),:),ln,kk2(timev(2),:),ln,kk2(timev(3),:),ln,kk2(timev(4),:),ln,kk2(timev(5),:)),
xlabel(‘Kanal’);ylabel(‘Konsentrasi’);
legend(‘600 s’,’1200 s’,’1800 s’,’2400 s’,’3000 s’);
title(‘Grafik Perubahan Konsentrasi Terhadap Ruang untuk u2 Polutan Kontinu dengan Metode Upstream’);
set(20,’Position’,get(0,’Screensize’));
saveas(20,’Grafik Perubahan Konsentrasi terhadap Ruang untuk u2 Polutan Kontinu dengan Metode Upstream.jpg’);
%%ploting u1 diskontinu
figure(21);
plot(t,kd1(:,tiv(1)),t,kd1(:,tiv(2)),t,kd1(:,tiv(3)),t,kd1(:,tiv(4)),t,kd1(:,tiv(5)));
xlabel(‘waktu (s)’);ylabel(‘konsentrasi’);
legend(‘100 m’,’500 m’,’1000 m’,’1500 m’,’2000 m’);
title(‘Grafik Perubahan Konsentrasi Terhadap waktu untuk u1 Polutan diskontinu dengan Metode Upstream’);
set(21,’Position’,get(0,’Screensize’));
saveas(21,’Grafik Perubahan Konsentrasi terhadap Waktu untuk u1 Polutan diskontinu dengan Metode Upstream.jpg’);
figure(22);
plot(ln,kd1(timev(1),:),ln,kd1(timev(2),:),ln,kd1(timev(3),:),ln,kd1(timev(4),:),ln,kd1(timev(5),:)),
xlabel(‘Kanal’);ylabel(‘Konsentrasi’);
legend(‘600 s’,’1200 s’,’1800 s’,’2400 s’,’3000 s’);
title(‘Grafik Perubahan Konsentrasi Terhadap Ruang untuk u1 Polutan diskontinu dengan Metode Upstream’);
set(22,’Position’,get(0,’Screensize’));
saveas(22,’Grafik Perubahan Konsentrasi terhadap Ruang untuk u1 Polutan diskontinu dengan Metode Upstream.jpg’);
%%ploting u2 diskontinu
figure(23);
plot(t,kd2(:,tiv(1)),t,kd2(:,tiv(2)),t,kd2(:,tiv(3)),t,kd2(:,tiv(4)),t,kd2(:,tiv(5)));
xlabel(‘waktu (s)’);ylabel(‘konsentrasi’);
legend(‘100 m’,’500 m’,’1000 m’,’1500 m’,’2000 m’);
title(‘Grafik Perubahan Konsentrasi Terhadap waktu untuk u2 Polutan diskontinu dengan Metode Upstream’);
set(23,’Position’,get(0,’Screensize’));
saveas(23,’Grafik Perubahan Konsentrasi terhadap Waktu untuk u2 Polutan diskontinu dengan Metode Upstream.jpg’);
figure(24);
plot(ln,kd2(timev(1),:),ln,kd2(timev(2),:),ln,kd2(timev(3),:),ln,kd2(timev(4),:),ln,kd2(timev(5),:)),
xlabel(‘Kanal’);ylabel(‘Konsentrasi’);
legend(‘600 s’,’1200 s’,’1800 s’,’2400 s’,’3000 s’);
title(‘Grafik Perubahan Konsentrasi Terhadap Ruang untuk u2 Polutan diskontinu dengan Metode Upstream’);
set(24,’Position’,get(0,’Screensize’));
saveas(24,’Grafik Perubahan Konsentrasi terhadap Ruang untuk u2 Polutan diskontinu dengan Metode Upstream.jpg’);
|when i tried to run it appear error like this|
Warning: File ‘./Grafik Perubahan
Konsentrasi terhadap Waktu untuk u2
Polutan diskontinu dengan Metode
Upstream.jpg’ not found.
> In matlab.graphics.internal.name (line 108)
In print (line 71)
In saveas (line 181)
In UpStreamTUGAS (line 166)
Error using print (line 90)
Output file ‘./Grafik Perubahan
Konsentrasi terhadap Waktu untuk u2
Polutan diskontinu dengan Metode
Upstream.jpg’ was not created. The file
name may not be valid.
Error in saveas (line 181)
print( h, name, [‘-d’ dev{i}] )
Error in UpStreamTUGAS (line 166)
saveas(23,’Grafik Perubahan Konsentrasi terhadap Waktu untuk u2 Polutan diskontinu dengan Metode Upstream.jpg’);clear all;
clc
%————————Menentukan Parameter—————%
L=2000; % panjang kanal(m)
T=3600; % lama simulasi (s)
dx=20; % lebar grid (m)
ln=0:dx:L;
y=length(ln); % panjang grid
n=L/dx; % jumlah grid
dt=2;
t=0:dt:T;
var=length(t); % panjang waktu
u1=-0.245;
u2=0.215;
pc=75; % polutan kontinu
pdc=100; % polutan diskontinu
%—————–Menentukan Domain——————-%
%skenario 1 (u1 polutan kontinu)
kk1=zeros(var,y); % nilai awal
kk1(:,15)=pc; % nilai konsentrasi polutan kontinu
%skenario 2 (u2 polutan kontinu)
kk2=zeros(var,y); % nilai awal
kk2(:,15)=pc; % nilai konsentrasi polutan kontinu
%skenario 3 (u1 polutan diskontinu)
kd1=zeros(var,y); % nilai awal
kd1(19,11)=pdc; % nilai konsentrasi polutan kontinu
%skenario 4 (u2 polutan diskontinu)
kd2=zeros(var,y); % nilai awal
kd2(19,11)=pdc; % nilai konsentrasi polutan kontinu
%—————-Perhitungan Upstream—————%
%%—skenario 1 dan 3 (untuk polutan u1)—–%%
lam1=(dt/(2*dx)); % konstanta untk numerik untuk polutan u1
if(-1<=lam1<=1); % syarat perhitungan upstream
disp(‘Model Jalan’);
else
return
end
%%% u1 kontinu
for np=1:var-1; % looping waktu
for i=2:y-1; % looping ruang
a=u1-abs(u1);
b=kk1(np,i+1)-kk1(np,i);
c=u1+abs(u1);
d=kk1(np,i)-kk1(np,i-1);
kk1(np+1,i)=kk1(np,i)-lam1*((a*b)+(c*d));
end;
kk1(:,15)=pc;
kk1(np,1)=kk1(np,2); %nilai batas kiri
kk1(np,y)=kk1(np,y-1); %niai batas kanan
end;
%%% u1 diskontinu
for np=1:var-1; % looping waktu
for i=2:y-1; % looping ruang
a=u1-abs(u1);
b=kd1(np,i+1)-kd1(np,i);
c=u1+abs(u1);
d=kd1(np,i)-kd1(np,i-1);
kd1(np+1,i)=kd1(np,i)-lam1*((a*b)+(c*d));
end;
kd1(19,11)=pc;
kd1(np,1)=kd1(np,2);
kd1(np,y)=kd1(np,y-1);
end;
%%———–skenario 2 dan 4 (untuk polutan u2)————-%
%%% u2 kontinu
for np=1:var-1; % looping waktu
for i=2:y-1; % looping ruang
a=u2-abs(u2);
b=kk2(np,i+1)-kk2(np,i);
c=u2+abs(u2);
d=kk2(np,i)-kk2(np,i-1);
kk2(np+1,i)=kk2(np,i)-lam1*((a*b)+(c*d));
end;
kk2(:,15)=pc;
kk2(np,1)=kk2(np,2);
kk2(np,y)=kk2(np,y-1);
end;
%% u2 diskontinu
for np=1:var-1; % looping waktu
for i=2:y-1; % looping ruang
a=u2-abs(u2);
b=kd2(np,i+1)-kd2(np,i);
c=u2+abs(u2);
d=kd2(np,i)-kd2(np,i-1);
kd2(np+1,i)=kd2(np,i)-lam1*((a*b)+(c*d));
end;
kd2(19,11)=pc;
kd2(np,1)=kd2(np,2);
kd2(np,y)=kd2(np,y-1);
end;
%—————ploting——————–%
timev=[300 600 900 1200 1500];
tiv=[5 25 50 75 100];
%ploting u1 kontinu
figure(17);
plot(t,kk1(:,tiv(1)),t,kk1(:,tiv(2)),t,kk1(:,tiv(3)),t,kk1(:,tiv(4)),t,kk1(:,tiv(5)));
xlabel(‘waktu (s)’);ylabel(‘konsentrasi’);
legend(‘100 m’,’500 m’,’1000 m’,’1500 m’,’2000 m’);
title(‘Grafik Perubahan Konsentrasi Terhadap waktu untuk u1 polutan kontinu dengan metode Upstream’);
set(17,’Position’,get(0,’Screensize’));
saveas(17,’Grafik Perubahan Konsentrasi terhadap Waktu untuk u1 Polutan Kontinu dengan Metode Upstream.jpg’);
figure (18);
plot(ln,kk1(timev(1),:),ln,kk1(timev(2),:),ln,kk1(timev(3),:),ln,kk1(timev(4),:),ln,kk1(timev(5),:)),
xlabel(‘Kanal’);ylabel(‘Konsentrasi’);
legend(‘600 s’,’1200 s’,’1800 s’,’2400 s’,’3000 s’);
title(‘Grafik Perubahan Konsentrasi Terhadap Ruang untuk u1 Polutan Kontinu dengan Metode Upstream’);
set(18,’Position’,get(0,’Screensize’));
saveas(18,’Grafik Perubahan Konsentrasi terhadap ruang untuk u1 Polutan Kontinu dengan Metode Upstream.jpg’);
%%Ploting u2 kontinu
figure(19);
plot(t,kk2(:,tiv(1)),t,kk2(:,tiv(2)),t,kk2(:,tiv(3)),t,kk2(:,tiv(4)),t,kk2(:,tiv(5)));
xlabel(‘waktu (s)’);ylabel(‘konsentrasi’);
legend(‘100 m’,’500 m’,’1000 m’,’1500 m’,’2000 m’);
title(‘Grafik Perubahan Konsentrasi Terhadap waktu untuk u2 Polutan Kontinu dengan Metode Upstream’);
set(19,’Position’,get(0,’Screensize’));
saveas(19,’Grafik Perubahan Konsentrasi terhadap Waktu untuk u2 Polutan Kontinu dengan Metode Upstream.jpg’);
figure(20);
plot(ln,kk2(timev(1),:),ln,kk2(timev(2),:),ln,kk2(timev(3),:),ln,kk2(timev(4),:),ln,kk2(timev(5),:)),
xlabel(‘Kanal’);ylabel(‘Konsentrasi’);
legend(‘600 s’,’1200 s’,’1800 s’,’2400 s’,’3000 s’);
title(‘Grafik Perubahan Konsentrasi Terhadap Ruang untuk u2 Polutan Kontinu dengan Metode Upstream’);
set(20,’Position’,get(0,’Screensize’));
saveas(20,’Grafik Perubahan Konsentrasi terhadap Ruang untuk u2 Polutan Kontinu dengan Metode Upstream.jpg’);
%%ploting u1 diskontinu
figure(21);
plot(t,kd1(:,tiv(1)),t,kd1(:,tiv(2)),t,kd1(:,tiv(3)),t,kd1(:,tiv(4)),t,kd1(:,tiv(5)));
xlabel(‘waktu (s)’);ylabel(‘konsentrasi’);
legend(‘100 m’,’500 m’,’1000 m’,’1500 m’,’2000 m’);
title(‘Grafik Perubahan Konsentrasi Terhadap waktu untuk u1 Polutan diskontinu dengan Metode Upstream’);
set(21,’Position’,get(0,’Screensize’));
saveas(21,’Grafik Perubahan Konsentrasi terhadap Waktu untuk u1 Polutan diskontinu dengan Metode Upstream.jpg’);
figure(22);
plot(ln,kd1(timev(1),:),ln,kd1(timev(2),:),ln,kd1(timev(3),:),ln,kd1(timev(4),:),ln,kd1(timev(5),:)),
xlabel(‘Kanal’);ylabel(‘Konsentrasi’);
legend(‘600 s’,’1200 s’,’1800 s’,’2400 s’,’3000 s’);
title(‘Grafik Perubahan Konsentrasi Terhadap Ruang untuk u1 Polutan diskontinu dengan Metode Upstream’);
set(22,’Position’,get(0,’Screensize’));
saveas(22,’Grafik Perubahan Konsentrasi terhadap Ruang untuk u1 Polutan diskontinu dengan Metode Upstream.jpg’);
%%ploting u2 diskontinu
figure(23);
plot(t,kd2(:,tiv(1)),t,kd2(:,tiv(2)),t,kd2(:,tiv(3)),t,kd2(:,tiv(4)),t,kd2(:,tiv(5)));
xlabel(‘waktu (s)’);ylabel(‘konsentrasi’);
legend(‘100 m’,’500 m’,’1000 m’,’1500 m’,’2000 m’);
title(‘Grafik Perubahan Konsentrasi Terhadap waktu untuk u2 Polutan diskontinu dengan Metode Upstream’);
set(23,’Position’,get(0,’Screensize’));
saveas(23,’Grafik Perubahan Konsentrasi terhadap Waktu untuk u2 Polutan diskontinu dengan Metode Upstream.jpg’);
figure(24);
plot(ln,kd2(timev(1),:),ln,kd2(timev(2),:),ln,kd2(timev(3),:),ln,kd2(timev(4),:),ln,kd2(timev(5),:)),
xlabel(‘Kanal’);ylabel(‘Konsentrasi’);
legend(‘600 s’,’1200 s’,’1800 s’,’2400 s’,’3000 s’);
title(‘Grafik Perubahan Konsentrasi Terhadap Ruang untuk u2 Polutan diskontinu dengan Metode Upstream’);
set(24,’Position’,get(0,’Screensize’));
saveas(24,’Grafik Perubahan Konsentrasi terhadap Ruang untuk u2 Polutan diskontinu dengan Metode Upstream.jpg’);
|when i tried to run it appear error like this|
Warning: File ‘./Grafik Perubahan
Konsentrasi terhadap Waktu untuk u2
Polutan diskontinu dengan Metode
Upstream.jpg’ not found.
> In matlab.graphics.internal.name (line 108)
In print (line 71)
In saveas (line 181)
In UpStreamTUGAS (line 166)
Error using print (line 90)
Output file ‘./Grafik Perubahan
Konsentrasi terhadap Waktu untuk u2
Polutan diskontinu dengan Metode
Upstream.jpg’ was not created. The file
name may not be valid.
Error in saveas (line 181)
print( h, name, [‘-d’ dev{i}] )
Error in UpStreamTUGAS (line 166)
saveas(23,’Grafik Perubahan Konsentrasi terhadap Waktu untuk u2 Polutan diskontinu dengan Metode Upstream.jpg’); clear all;
clc
%————————Menentukan Parameter—————%
L=2000; % panjang kanal(m)
T=3600; % lama simulasi (s)
dx=20; % lebar grid (m)
ln=0:dx:L;
y=length(ln); % panjang grid
n=L/dx; % jumlah grid
dt=2;
t=0:dt:T;
var=length(t); % panjang waktu
u1=-0.245;
u2=0.215;
pc=75; % polutan kontinu
pdc=100; % polutan diskontinu
%—————–Menentukan Domain——————-%
%skenario 1 (u1 polutan kontinu)
kk1=zeros(var,y); % nilai awal
kk1(:,15)=pc; % nilai konsentrasi polutan kontinu
%skenario 2 (u2 polutan kontinu)
kk2=zeros(var,y); % nilai awal
kk2(:,15)=pc; % nilai konsentrasi polutan kontinu
%skenario 3 (u1 polutan diskontinu)
kd1=zeros(var,y); % nilai awal
kd1(19,11)=pdc; % nilai konsentrasi polutan kontinu
%skenario 4 (u2 polutan diskontinu)
kd2=zeros(var,y); % nilai awal
kd2(19,11)=pdc; % nilai konsentrasi polutan kontinu
%—————-Perhitungan Upstream—————%
%%—skenario 1 dan 3 (untuk polutan u1)—–%%
lam1=(dt/(2*dx)); % konstanta untk numerik untuk polutan u1
if(-1<=lam1<=1); % syarat perhitungan upstream
disp(‘Model Jalan’);
else
return
end
%%% u1 kontinu
for np=1:var-1; % looping waktu
for i=2:y-1; % looping ruang
a=u1-abs(u1);
b=kk1(np,i+1)-kk1(np,i);
c=u1+abs(u1);
d=kk1(np,i)-kk1(np,i-1);
kk1(np+1,i)=kk1(np,i)-lam1*((a*b)+(c*d));
end;
kk1(:,15)=pc;
kk1(np,1)=kk1(np,2); %nilai batas kiri
kk1(np,y)=kk1(np,y-1); %niai batas kanan
end;
%%% u1 diskontinu
for np=1:var-1; % looping waktu
for i=2:y-1; % looping ruang
a=u1-abs(u1);
b=kd1(np,i+1)-kd1(np,i);
c=u1+abs(u1);
d=kd1(np,i)-kd1(np,i-1);
kd1(np+1,i)=kd1(np,i)-lam1*((a*b)+(c*d));
end;
kd1(19,11)=pc;
kd1(np,1)=kd1(np,2);
kd1(np,y)=kd1(np,y-1);
end;
%%———–skenario 2 dan 4 (untuk polutan u2)————-%
%%% u2 kontinu
for np=1:var-1; % looping waktu
for i=2:y-1; % looping ruang
a=u2-abs(u2);
b=kk2(np,i+1)-kk2(np,i);
c=u2+abs(u2);
d=kk2(np,i)-kk2(np,i-1);
kk2(np+1,i)=kk2(np,i)-lam1*((a*b)+(c*d));
end;
kk2(:,15)=pc;
kk2(np,1)=kk2(np,2);
kk2(np,y)=kk2(np,y-1);
end;
%% u2 diskontinu
for np=1:var-1; % looping waktu
for i=2:y-1; % looping ruang
a=u2-abs(u2);
b=kd2(np,i+1)-kd2(np,i);
c=u2+abs(u2);
d=kd2(np,i)-kd2(np,i-1);
kd2(np+1,i)=kd2(np,i)-lam1*((a*b)+(c*d));
end;
kd2(19,11)=pc;
kd2(np,1)=kd2(np,2);
kd2(np,y)=kd2(np,y-1);
end;
%—————ploting——————–%
timev=[300 600 900 1200 1500];
tiv=[5 25 50 75 100];
%ploting u1 kontinu
figure(17);
plot(t,kk1(:,tiv(1)),t,kk1(:,tiv(2)),t,kk1(:,tiv(3)),t,kk1(:,tiv(4)),t,kk1(:,tiv(5)));
xlabel(‘waktu (s)’);ylabel(‘konsentrasi’);
legend(‘100 m’,’500 m’,’1000 m’,’1500 m’,’2000 m’);
title(‘Grafik Perubahan Konsentrasi Terhadap waktu untuk u1 polutan kontinu dengan metode Upstream’);
set(17,’Position’,get(0,’Screensize’));
saveas(17,’Grafik Perubahan Konsentrasi terhadap Waktu untuk u1 Polutan Kontinu dengan Metode Upstream.jpg’);
figure (18);
plot(ln,kk1(timev(1),:),ln,kk1(timev(2),:),ln,kk1(timev(3),:),ln,kk1(timev(4),:),ln,kk1(timev(5),:)),
xlabel(‘Kanal’);ylabel(‘Konsentrasi’);
legend(‘600 s’,’1200 s’,’1800 s’,’2400 s’,’3000 s’);
title(‘Grafik Perubahan Konsentrasi Terhadap Ruang untuk u1 Polutan Kontinu dengan Metode Upstream’);
set(18,’Position’,get(0,’Screensize’));
saveas(18,’Grafik Perubahan Konsentrasi terhadap ruang untuk u1 Polutan Kontinu dengan Metode Upstream.jpg’);
%%Ploting u2 kontinu
figure(19);
plot(t,kk2(:,tiv(1)),t,kk2(:,tiv(2)),t,kk2(:,tiv(3)),t,kk2(:,tiv(4)),t,kk2(:,tiv(5)));
xlabel(‘waktu (s)’);ylabel(‘konsentrasi’);
legend(‘100 m’,’500 m’,’1000 m’,’1500 m’,’2000 m’);
title(‘Grafik Perubahan Konsentrasi Terhadap waktu untuk u2 Polutan Kontinu dengan Metode Upstream’);
set(19,’Position’,get(0,’Screensize’));
saveas(19,’Grafik Perubahan Konsentrasi terhadap Waktu untuk u2 Polutan Kontinu dengan Metode Upstream.jpg’);
figure(20);
plot(ln,kk2(timev(1),:),ln,kk2(timev(2),:),ln,kk2(timev(3),:),ln,kk2(timev(4),:),ln,kk2(timev(5),:)),
xlabel(‘Kanal’);ylabel(‘Konsentrasi’);
legend(‘600 s’,’1200 s’,’1800 s’,’2400 s’,’3000 s’);
title(‘Grafik Perubahan Konsentrasi Terhadap Ruang untuk u2 Polutan Kontinu dengan Metode Upstream’);
set(20,’Position’,get(0,’Screensize’));
saveas(20,’Grafik Perubahan Konsentrasi terhadap Ruang untuk u2 Polutan Kontinu dengan Metode Upstream.jpg’);
%%ploting u1 diskontinu
figure(21);
plot(t,kd1(:,tiv(1)),t,kd1(:,tiv(2)),t,kd1(:,tiv(3)),t,kd1(:,tiv(4)),t,kd1(:,tiv(5)));
xlabel(‘waktu (s)’);ylabel(‘konsentrasi’);
legend(‘100 m’,’500 m’,’1000 m’,’1500 m’,’2000 m’);
title(‘Grafik Perubahan Konsentrasi Terhadap waktu untuk u1 Polutan diskontinu dengan Metode Upstream’);
set(21,’Position’,get(0,’Screensize’));
saveas(21,’Grafik Perubahan Konsentrasi terhadap Waktu untuk u1 Polutan diskontinu dengan Metode Upstream.jpg’);
figure(22);
plot(ln,kd1(timev(1),:),ln,kd1(timev(2),:),ln,kd1(timev(3),:),ln,kd1(timev(4),:),ln,kd1(timev(5),:)),
xlabel(‘Kanal’);ylabel(‘Konsentrasi’);
legend(‘600 s’,’1200 s’,’1800 s’,’2400 s’,’3000 s’);
title(‘Grafik Perubahan Konsentrasi Terhadap Ruang untuk u1 Polutan diskontinu dengan Metode Upstream’);
set(22,’Position’,get(0,’Screensize’));
saveas(22,’Grafik Perubahan Konsentrasi terhadap Ruang untuk u1 Polutan diskontinu dengan Metode Upstream.jpg’);
%%ploting u2 diskontinu
figure(23);
plot(t,kd2(:,tiv(1)),t,kd2(:,tiv(2)),t,kd2(:,tiv(3)),t,kd2(:,tiv(4)),t,kd2(:,tiv(5)));
xlabel(‘waktu (s)’);ylabel(‘konsentrasi’);
legend(‘100 m’,’500 m’,’1000 m’,’1500 m’,’2000 m’);
title(‘Grafik Perubahan Konsentrasi Terhadap waktu untuk u2 Polutan diskontinu dengan Metode Upstream’);
set(23,’Position’,get(0,’Screensize’));
saveas(23,’Grafik Perubahan Konsentrasi terhadap Waktu untuk u2 Polutan diskontinu dengan Metode Upstream.jpg’);
figure(24);
plot(ln,kd2(timev(1),:),ln,kd2(timev(2),:),ln,kd2(timev(3),:),ln,kd2(timev(4),:),ln,kd2(timev(5),:)),
xlabel(‘Kanal’);ylabel(‘Konsentrasi’);
legend(‘600 s’,’1200 s’,’1800 s’,’2400 s’,’3000 s’);
title(‘Grafik Perubahan Konsentrasi Terhadap Ruang untuk u2 Polutan diskontinu dengan Metode Upstream’);
set(24,’Position’,get(0,’Screensize’));
saveas(24,’Grafik Perubahan Konsentrasi terhadap Ruang untuk u2 Polutan diskontinu dengan Metode Upstream.jpg’);
|when i tried to run it appear error like this|
Warning: File ‘./Grafik Perubahan
Konsentrasi terhadap Waktu untuk u2
Polutan diskontinu dengan Metode
Upstream.jpg’ not found.
> In matlab.graphics.internal.name (line 108)
In print (line 71)
In saveas (line 181)
In UpStreamTUGAS (line 166)
Error using print (line 90)
Output file ‘./Grafik Perubahan
Konsentrasi terhadap Waktu untuk u2
Polutan diskontinu dengan Metode
Upstream.jpg’ was not created. The file
name may not be valid.
Error in saveas (line 181)
print( h, name, [‘-d’ dev{i}] )
Error in UpStreamTUGAS (line 166)
saveas(23,’Grafik Perubahan Konsentrasi terhadap Waktu untuk u2 Polutan diskontinu dengan Metode Upstream.jpg’); saveas, save, image, jpg, upstream MATLAB Answers — New Questions
[0:0.1:1] whys is not exactly 0.1 steps ?
Anyone know why this code does not return verification 1
it seems instead of being 0.1 is actually makaing 0.10000000001
step=0.1;
max_value=1;
array = 0:step:max_value;
array1 = round(0:step:max_value,1);
check=[array’,array1′];
test=[array==array1]’;
% Why not 1 ?
verification=all(test)Anyone know why this code does not return verification 1
it seems instead of being 0.1 is actually makaing 0.10000000001
step=0.1;
max_value=1;
array = 0:step:max_value;
array1 = round(0:step:max_value,1);
check=[array’,array1′];
test=[array==array1]’;
% Why not 1 ?
verification=all(test) Anyone know why this code does not return verification 1
it seems instead of being 0.1 is actually makaing 0.10000000001
step=0.1;
max_value=1;
array = 0:step:max_value;
array1 = round(0:step:max_value,1);
check=[array’,array1′];
test=[array==array1]’;
% Why not 1 ?
verification=all(test) resolution MATLAB Answers — New Questions
What is the fcnLossLayer in the generatePolicyFunction network and how can I implement it myself?
I wish to use my trained SAC agent in Matlab only as a policy function. For this, I tried the generatePolicyFunction option. The code and the network works as intended, but I’m having a hard time figuring out the last layer of the network. It says it’s a fcnLossLayer, although I have no idea what does it mean or how does it work. It’s description is very vauge:
>> policy.Layers(11, 1)
ans =
FcnLossLayer with properties:
LossFcn: []
IsNetworkStateful: 0
Name: ‘RepresentationLoss’
ResponseNames: {}
Description: ”
Type: "GenericLossLayer"
This is the only information I get from the DAGNetwork object and it makes no sense to me. Also I couldn’t find any relevant information in the documentation, or in the referenced articles, or anywhere on the internet. I found it’s type is rl.layer.FcnLossLayer, but searching for this I still got nothing. This seams to me like a focalLossLayer, but even if it is, I don’t know its parameters.
This is important to me because I want to use this policy in a previous Matlab version (R2020a), and it doesn’t seem to support this layer, so I want to try and implement it as a custom layer. Thank you for your help in advance!I wish to use my trained SAC agent in Matlab only as a policy function. For this, I tried the generatePolicyFunction option. The code and the network works as intended, but I’m having a hard time figuring out the last layer of the network. It says it’s a fcnLossLayer, although I have no idea what does it mean or how does it work. It’s description is very vauge:
>> policy.Layers(11, 1)
ans =
FcnLossLayer with properties:
LossFcn: []
IsNetworkStateful: 0
Name: ‘RepresentationLoss’
ResponseNames: {}
Description: ”
Type: "GenericLossLayer"
This is the only information I get from the DAGNetwork object and it makes no sense to me. Also I couldn’t find any relevant information in the documentation, or in the referenced articles, or anywhere on the internet. I found it’s type is rl.layer.FcnLossLayer, but searching for this I still got nothing. This seams to me like a focalLossLayer, but even if it is, I don’t know its parameters.
This is important to me because I want to use this policy in a previous Matlab version (R2020a), and it doesn’t seem to support this layer, so I want to try and implement it as a custom layer. Thank you for your help in advance! I wish to use my trained SAC agent in Matlab only as a policy function. For this, I tried the generatePolicyFunction option. The code and the network works as intended, but I’m having a hard time figuring out the last layer of the network. It says it’s a fcnLossLayer, although I have no idea what does it mean or how does it work. It’s description is very vauge:
>> policy.Layers(11, 1)
ans =
FcnLossLayer with properties:
LossFcn: []
IsNetworkStateful: 0
Name: ‘RepresentationLoss’
ResponseNames: {}
Description: ”
Type: "GenericLossLayer"
This is the only information I get from the DAGNetwork object and it makes no sense to me. Also I couldn’t find any relevant information in the documentation, or in the referenced articles, or anywhere on the internet. I found it’s type is rl.layer.FcnLossLayer, but searching for this I still got nothing. This seams to me like a focalLossLayer, but even if it is, I don’t know its parameters.
This is important to me because I want to use this policy in a previous Matlab version (R2020a), and it doesn’t seem to support this layer, so I want to try and implement it as a custom layer. Thank you for your help in advance! rlsacagent, generatepolicyfunction, fcnlosslayer, matlab, neural network, rl.layer.fcnlosslayer MATLAB Answers — New Questions
how I solve the two equation and two unknown variables using ‘levenberg-marquardt’ method?
I wnat to solve follow two equations.
F = @(X) [d(1,3).*(abs(X(1)./(X(2).^2.*ar))+d(2,3).*(X(1)./(X(2).^2.*ar))).^d(3,3).*(bg_loc_M)+d(4,3).*(X(2)).^d(5,3)-l./X(2);
abs(c(1,3)).*(bg_loc_M).^c(2,3).*X(2).^c(3,3).*(ar).^c(4,3).*exp(-abs(c(5,3)).*abs(X(1)+c(6,3).*abs(X(1))).^abs(c(7,3)))-foc];
here, I don’t know X(1) & X(2), and kown others
how I solve the X(1) and X(2)?
I want to use levenberg-marquardt method.
I did follow.
F = @(X) [d(1,3).*(abs(X(1)./(X(2).^2.*ar))+d(2,3).*(X(1)./(X(2).^2.*ar))).^d(3,3).*(bg_loc_M)+d(4,3).*(X(2)).^d(5,3)-l./X(2);
abs(c(1,3)).*(bg_loc_M).^c(2,3).*X(2).^c(3,3).*(ar).^c(4,3).*exp(-abs(c(5,3)).*abs(X(1)+c(6,3).*abs(X(1))).^abs(c(7,3)))-foc];
x0=[0 l];
opts.Algorithm = ‘levenberg-marquardt’;
opts.TolX = 1e-10;
recal=fsolve(F,x0,opts);
But, results of X(1) & X(2) are different real value…..
I need your advice.I wnat to solve follow two equations.
F = @(X) [d(1,3).*(abs(X(1)./(X(2).^2.*ar))+d(2,3).*(X(1)./(X(2).^2.*ar))).^d(3,3).*(bg_loc_M)+d(4,3).*(X(2)).^d(5,3)-l./X(2);
abs(c(1,3)).*(bg_loc_M).^c(2,3).*X(2).^c(3,3).*(ar).^c(4,3).*exp(-abs(c(5,3)).*abs(X(1)+c(6,3).*abs(X(1))).^abs(c(7,3)))-foc];
here, I don’t know X(1) & X(2), and kown others
how I solve the X(1) and X(2)?
I want to use levenberg-marquardt method.
I did follow.
F = @(X) [d(1,3).*(abs(X(1)./(X(2).^2.*ar))+d(2,3).*(X(1)./(X(2).^2.*ar))).^d(3,3).*(bg_loc_M)+d(4,3).*(X(2)).^d(5,3)-l./X(2);
abs(c(1,3)).*(bg_loc_M).^c(2,3).*X(2).^c(3,3).*(ar).^c(4,3).*exp(-abs(c(5,3)).*abs(X(1)+c(6,3).*abs(X(1))).^abs(c(7,3)))-foc];
x0=[0 l];
opts.Algorithm = ‘levenberg-marquardt’;
opts.TolX = 1e-10;
recal=fsolve(F,x0,opts);
But, results of X(1) & X(2) are different real value…..
I need your advice. I wnat to solve follow two equations.
F = @(X) [d(1,3).*(abs(X(1)./(X(2).^2.*ar))+d(2,3).*(X(1)./(X(2).^2.*ar))).^d(3,3).*(bg_loc_M)+d(4,3).*(X(2)).^d(5,3)-l./X(2);
abs(c(1,3)).*(bg_loc_M).^c(2,3).*X(2).^c(3,3).*(ar).^c(4,3).*exp(-abs(c(5,3)).*abs(X(1)+c(6,3).*abs(X(1))).^abs(c(7,3)))-foc];
here, I don’t know X(1) & X(2), and kown others
how I solve the X(1) and X(2)?
I want to use levenberg-marquardt method.
I did follow.
F = @(X) [d(1,3).*(abs(X(1)./(X(2).^2.*ar))+d(2,3).*(X(1)./(X(2).^2.*ar))).^d(3,3).*(bg_loc_M)+d(4,3).*(X(2)).^d(5,3)-l./X(2);
abs(c(1,3)).*(bg_loc_M).^c(2,3).*X(2).^c(3,3).*(ar).^c(4,3).*exp(-abs(c(5,3)).*abs(X(1)+c(6,3).*abs(X(1))).^abs(c(7,3)))-foc];
x0=[0 l];
opts.Algorithm = ‘levenberg-marquardt’;
opts.TolX = 1e-10;
recal=fsolve(F,x0,opts);
But, results of X(1) & X(2) are different real value…..
I need your advice. levenberg-marquardt, non-liner, fsolve, lsqcurvefit MATLAB Answers — New Questions
I have a hexacopter simulink model attached with the controllers and after a particular simulation time my roll pitch and yaw values rapidly increases and simulation stops.
Post Content Post Content solver MATLAB Answers — New Questions
Find intercept point with three boundary conditions
Hi,
Im trying to find a point in a straight line given by an equation F(x)=mx+b, with the following boundary conditions:
-is a tangent of a semicircle
-The semicircle has a center on the horizontal axis
-the semicircle goes thru the origin (x=0, y=0)
Initially I was plotting the line and then start modifying the radius manually of the semicircle until I found one intersection point using InterX, but I think it might exist a way to avoid the manual modification.Hi,
Im trying to find a point in a straight line given by an equation F(x)=mx+b, with the following boundary conditions:
-is a tangent of a semicircle
-The semicircle has a center on the horizontal axis
-the semicircle goes thru the origin (x=0, y=0)
Initially I was plotting the line and then start modifying the radius manually of the semicircle until I found one intersection point using InterX, but I think it might exist a way to avoid the manual modification. Hi,
Im trying to find a point in a straight line given by an equation F(x)=mx+b, with the following boundary conditions:
-is a tangent of a semicircle
-The semicircle has a center on the horizontal axis
-the semicircle goes thru the origin (x=0, y=0)
Initially I was plotting the line and then start modifying the radius manually of the semicircle until I found one intersection point using InterX, but I think it might exist a way to avoid the manual modification. semicirle tangent MATLAB Answers — New Questions
Can I used hte Spi WriteRead Block with just any SPI device or should it be only with arduino
I have a SPI slave device which is modeled in Simulink via the FIL ( FPGA in LOOP) approach. Would it be possible to use the SPI WriteRead Block available to communicate to this model ?I have a SPI slave device which is modeled in Simulink via the FIL ( FPGA in LOOP) approach. Would it be possible to use the SPI WriteRead Block available to communicate to this model ? I have a SPI slave device which is modeled in Simulink via the FIL ( FPGA in LOOP) approach. Would it be possible to use the SPI WriteRead Block available to communicate to this model ? spi, writeread, simulink, fil, fpga in loop MATLAB Answers — New Questions
Channel Equalization for the comm.RayleighFading communication toolbox for Frequency Selective channel?
I recently used the comm.rayleighfading communication toolbox to create random channel taps with some correlation (Jakes, Clarkes Models). In flat fading it is easy to obtain the H matrix and equalize accordingly. However, I dont know how it should be done using this toolbox in multipath frequency selective channels.
I want to use the channel output y and the path gains h to reconstruct the input signal x.
Thanks in advanceI recently used the comm.rayleighfading communication toolbox to create random channel taps with some correlation (Jakes, Clarkes Models). In flat fading it is easy to obtain the H matrix and equalize accordingly. However, I dont know how it should be done using this toolbox in multipath frequency selective channels.
I want to use the channel output y and the path gains h to reconstruct the input signal x.
Thanks in advance I recently used the comm.rayleighfading communication toolbox to create random channel taps with some correlation (Jakes, Clarkes Models). In flat fading it is easy to obtain the H matrix and equalize accordingly. However, I dont know how it should be done using this toolbox in multipath frequency selective channels.
I want to use the channel output y and the path gains h to reconstruct the input signal x.
Thanks in advance communications, channel, ofdm, rayleigh, equalization MATLAB Answers — New Questions
How is cell to cell gap in battery builder app is depicted in electrical circuit?
hi,
battery pack can be made either using simulink battery blocks or newly introduced "battery builder app". The latter gives an additional advantage of specifying the gap between cell to cell, parallel assembly and module assembly. i want to know how the "gap" that we provide during building battery pack in battery builder app is depicted in eletrical circuit or in the final battery pack? also can it be made a runtime parameter during simulation? if yes, please tell me how it can be done?
thank you.hi,
battery pack can be made either using simulink battery blocks or newly introduced "battery builder app". The latter gives an additional advantage of specifying the gap between cell to cell, parallel assembly and module assembly. i want to know how the "gap" that we provide during building battery pack in battery builder app is depicted in eletrical circuit or in the final battery pack? also can it be made a runtime parameter during simulation? if yes, please tell me how it can be done?
thank you. hi,
battery pack can be made either using simulink battery blocks or newly introduced "battery builder app". The latter gives an additional advantage of specifying the gap between cell to cell, parallel assembly and module assembly. i want to know how the "gap" that we provide during building battery pack in battery builder app is depicted in eletrical circuit or in the final battery pack? also can it be made a runtime parameter during simulation? if yes, please tell me how it can be done?
thank you. battery_system_management, simscape battery MATLAB Answers — New Questions
Hi i’m new to MatLab. Why I can’t get the values from matrix x in function MyInput() to calculate in another func and the command window says ‘Not enough input arguments. ‘?
function Calculate(x)
MyInput();
y = zeros(1,6);
for j=2:6
y(1,j) = x(1,j)^j;
j=j+1;
end
end
function x = MyInput()
x = zeros(1,6);
x(1,1) = 2;
for i=2:6
x(1,i)=x(1,i-1)+1;
i=i+1;
end
endfunction Calculate(x)
MyInput();
y = zeros(1,6);
for j=2:6
y(1,j) = x(1,j)^j;
j=j+1;
end
end
function x = MyInput()
x = zeros(1,6);
x(1,1) = 2;
for i=2:6
x(1,i)=x(1,i-1)+1;
i=i+1;
end
end function Calculate(x)
MyInput();
y = zeros(1,6);
for j=2:6
y(1,j) = x(1,j)^j;
j=j+1;
end
end
function x = MyInput()
x = zeros(1,6);
x(1,1) = 2;
for i=2:6
x(1,i)=x(1,i-1)+1;
i=i+1;
end
end #returnvalue, #function MATLAB Answers — New Questions
code written in MATLAB function should be paused for some instant but simulation should never be paused.
generally in my project capacitor voltages diverge. So, i have written a code to converge them to a nominal voltage.
Now i want observe whether my work was proper or not. for that i have three instances.
First: Both code and simulation should run
second: Code has to be disabled but simulation should be running.
Third: code has to be re-enabled and simulation should be running.
now my problem is, Is it possible disable entire code for some time but simulation should be running at the background?
and after some time can we re enable it?
Note: At any instant simulation should be running(i.e., simulation should not be paused or stopped)generally in my project capacitor voltages diverge. So, i have written a code to converge them to a nominal voltage.
Now i want observe whether my work was proper or not. for that i have three instances.
First: Both code and simulation should run
second: Code has to be disabled but simulation should be running.
Third: code has to be re-enabled and simulation should be running.
now my problem is, Is it possible disable entire code for some time but simulation should be running at the background?
and after some time can we re enable it?
Note: At any instant simulation should be running(i.e., simulation should not be paused or stopped) generally in my project capacitor voltages diverge. So, i have written a code to converge them to a nominal voltage.
Now i want observe whether my work was proper or not. for that i have three instances.
First: Both code and simulation should run
second: Code has to be disabled but simulation should be running.
Third: code has to be re-enabled and simulation should be running.
now my problem is, Is it possible disable entire code for some time but simulation should be running at the background?
and after some time can we re enable it?
Note: At any instant simulation should be running(i.e., simulation should not be paused or stopped) code, simulink MATLAB Answers — New Questions
inputdlg Window Not Showing
So I was creating an even or odd checker using inputdlg. However, when I ran it, the inputdlg window actually does not show up. Here is the code/proof that I used so far.
prompt={"Enter a 1 x 1 integer value:"}
dlgtitle="Even or odd test"
tmp=inputdlg(prompt,dlgtitle)
user_number=round(str2double(tmp))
if not(isnan(user_number))
fprintf("Number is valid.n")
if rem(user_number,2)==0
fprintf("Your number is even.n")
else
fprintf("Your number is odd.n")
end
else
fprintf("Number is not valid.n")
end
There aren’t any errors or warnings shown on there. Can someone tell me if there is a way to get the inputdlg window to show (if it has something to do with the code)?So I was creating an even or odd checker using inputdlg. However, when I ran it, the inputdlg window actually does not show up. Here is the code/proof that I used so far.
prompt={"Enter a 1 x 1 integer value:"}
dlgtitle="Even or odd test"
tmp=inputdlg(prompt,dlgtitle)
user_number=round(str2double(tmp))
if not(isnan(user_number))
fprintf("Number is valid.n")
if rem(user_number,2)==0
fprintf("Your number is even.n")
else
fprintf("Your number is odd.n")
end
else
fprintf("Number is not valid.n")
end
There aren’t any errors or warnings shown on there. Can someone tell me if there is a way to get the inputdlg window to show (if it has something to do with the code)? So I was creating an even or odd checker using inputdlg. However, when I ran it, the inputdlg window actually does not show up. Here is the code/proof that I used so far.
prompt={"Enter a 1 x 1 integer value:"}
dlgtitle="Even or odd test"
tmp=inputdlg(prompt,dlgtitle)
user_number=round(str2double(tmp))
if not(isnan(user_number))
fprintf("Number is valid.n")
if rem(user_number,2)==0
fprintf("Your number is even.n")
else
fprintf("Your number is odd.n")
end
else
fprintf("Number is not valid.n")
end
There aren’t any errors or warnings shown on there. Can someone tell me if there is a way to get the inputdlg window to show (if it has something to do with the code)? inputdlg MATLAB Answers — New Questions
How to write customer struct in TLC file for inline SFunction C++?
I have already rebuilt my C++ code in SFunction, and use "mex xxxxxx.cpp xxxxx.cpp " to run normal.
Next, I want to transform this SFunction to inline SFunction, and meet some problems.
In my code, I use
"typedef struct
{
}PIDController;
"
A customer struct, and work well.
Now, I want to use it in tlc file, how to do it?
Thank you all!!!I have already rebuilt my C++ code in SFunction, and use "mex xxxxxx.cpp xxxxx.cpp " to run normal.
Next, I want to transform this SFunction to inline SFunction, and meet some problems.
In my code, I use
"typedef struct
{
}PIDController;
"
A customer struct, and work well.
Now, I want to use it in tlc file, how to do it?
Thank you all!!! I have already rebuilt my C++ code in SFunction, and use "mex xxxxxx.cpp xxxxx.cpp " to run normal.
Next, I want to transform this SFunction to inline SFunction, and meet some problems.
In my code, I use
"typedef struct
{
}PIDController;
"
A customer struct, and work well.
Now, I want to use it in tlc file, how to do it?
Thank you all!!! sfunction, code generation, tlc MATLAB Answers — New Questions
input boxes of figure export do not work!
try to export a figure. but the option boxes do not work.try to export a figure. but the option boxes do not work. try to export a figure. but the option boxes do not work. figure MATLAB Answers — New Questions
Filtering Square Wave with Butterworth Filter using Fourier Coefficients
Hello there, I’m trying to filter a square wave with a 2nd order butterworth HPF in order to retrieve the fundamental sine wave with minimal attenuation. When I run my code to display the magnitude spectrum of the input and output coefficients, there is an attenuation of about 1.7dB. Yet when I reconstruct the signal, the resulting sine wave appears to be attenuated much more (about half the size of the input, about 6dB). This leads me to believe there is an issue with the second for loop but I am unable to find it. Any help would be much appreciated.
clear; clc;
T = 0.1; %in ms
F = 1/T; %in kHz
Fs = 1000;
offset = 0;
amp = 1;
duty = 50; %percent duty cycle
t = 0:0.001:0.5;
fc = 12; % in kHz
sq_wave = offset+amp*square(2*pi*F.*t,duty); %general square wave function
N=10; %no. of harmonics
nvec = -N:N;
c_in = zeros(size(nvec));
f = nvec*F;
for n = nvec
m = n+N+1;
c_in(m) = (1/2)*((sin(pi*n/2))/(pi*n/2)); %sinc function
if (n == 0)
c_in(m) = 0.0; %DC Offset
end
end
w = f/fc;
Hf = 1 ./ ((w*1i).^2 + 1.414*(w*1i) + 1);
c_out = c_in .* Hf;
stem(f,abs(c_in),’r’,’LineWidth’,1.5);
hold on
stem(f,abs(c_out),’b’,’LineWidth’,1.5);
hold off
title(‘Magnitude Spectrum of Filter Output and Input’)
A = zeros(2*N+1,length(t));
for n = nvec
m=n+N+1;
A(m,:) = c_out(m) .* exp(1i*2*pi*n*F.*t);
end
sine_wave = sum(A);
%plot(t,real(sine_wave),’b’,t,sq_wave,’r’);Hello there, I’m trying to filter a square wave with a 2nd order butterworth HPF in order to retrieve the fundamental sine wave with minimal attenuation. When I run my code to display the magnitude spectrum of the input and output coefficients, there is an attenuation of about 1.7dB. Yet when I reconstruct the signal, the resulting sine wave appears to be attenuated much more (about half the size of the input, about 6dB). This leads me to believe there is an issue with the second for loop but I am unable to find it. Any help would be much appreciated.
clear; clc;
T = 0.1; %in ms
F = 1/T; %in kHz
Fs = 1000;
offset = 0;
amp = 1;
duty = 50; %percent duty cycle
t = 0:0.001:0.5;
fc = 12; % in kHz
sq_wave = offset+amp*square(2*pi*F.*t,duty); %general square wave function
N=10; %no. of harmonics
nvec = -N:N;
c_in = zeros(size(nvec));
f = nvec*F;
for n = nvec
m = n+N+1;
c_in(m) = (1/2)*((sin(pi*n/2))/(pi*n/2)); %sinc function
if (n == 0)
c_in(m) = 0.0; %DC Offset
end
end
w = f/fc;
Hf = 1 ./ ((w*1i).^2 + 1.414*(w*1i) + 1);
c_out = c_in .* Hf;
stem(f,abs(c_in),’r’,’LineWidth’,1.5);
hold on
stem(f,abs(c_out),’b’,’LineWidth’,1.5);
hold off
title(‘Magnitude Spectrum of Filter Output and Input’)
A = zeros(2*N+1,length(t));
for n = nvec
m=n+N+1;
A(m,:) = c_out(m) .* exp(1i*2*pi*n*F.*t);
end
sine_wave = sum(A);
%plot(t,real(sine_wave),’b’,t,sq_wave,’r’); Hello there, I’m trying to filter a square wave with a 2nd order butterworth HPF in order to retrieve the fundamental sine wave with minimal attenuation. When I run my code to display the magnitude spectrum of the input and output coefficients, there is an attenuation of about 1.7dB. Yet when I reconstruct the signal, the resulting sine wave appears to be attenuated much more (about half the size of the input, about 6dB). This leads me to believe there is an issue with the second for loop but I am unable to find it. Any help would be much appreciated.
clear; clc;
T = 0.1; %in ms
F = 1/T; %in kHz
Fs = 1000;
offset = 0;
amp = 1;
duty = 50; %percent duty cycle
t = 0:0.001:0.5;
fc = 12; % in kHz
sq_wave = offset+amp*square(2*pi*F.*t,duty); %general square wave function
N=10; %no. of harmonics
nvec = -N:N;
c_in = zeros(size(nvec));
f = nvec*F;
for n = nvec
m = n+N+1;
c_in(m) = (1/2)*((sin(pi*n/2))/(pi*n/2)); %sinc function
if (n == 0)
c_in(m) = 0.0; %DC Offset
end
end
w = f/fc;
Hf = 1 ./ ((w*1i).^2 + 1.414*(w*1i) + 1);
c_out = c_in .* Hf;
stem(f,abs(c_in),’r’,’LineWidth’,1.5);
hold on
stem(f,abs(c_out),’b’,’LineWidth’,1.5);
hold off
title(‘Magnitude Spectrum of Filter Output and Input’)
A = zeros(2*N+1,length(t));
for n = nvec
m=n+N+1;
A(m,:) = c_out(m) .* exp(1i*2*pi*n*F.*t);
end
sine_wave = sum(A);
%plot(t,real(sine_wave),’b’,t,sq_wave,’r’); fourier series, signal processing, dsp, fourier coefficients MATLAB Answers — New Questions
The element 1 in SCDPotentialLinearizationIOs structure is not referring to an existing block in the model。
Hello,I don’t know where to operate when adjusting the PI control of the model, and suddenly the following error appears: The element 1 in SCDPotentialLinearizationIOs structure is not referring to an existing block in the model.Hello,I don’t know where to operate when adjusting the PI control of the model, and suddenly the following error appears: The element 1 in SCDPotentialLinearizationIOs structure is not referring to an existing block in the model. Hello,I don’t know where to operate when adjusting the PI control of the model, and suddenly the following error appears: The element 1 in SCDPotentialLinearizationIOs structure is not referring to an existing block in the model. pi control, MATLAB Answers — New Questions
Surface Texture Peak density and Peak curvature
I need to calculate the peak density of a 3D surface. The formula is simple: #of peaks/ Area. The area is easy to calculate but how can i count the number of peaks? The peak curvature is a bit more complicated and have no idea how to calculate so I will leave the equation below. Also an estimate of the local gradient vector is provided. Any idea is welcomedI need to calculate the peak density of a 3D surface. The formula is simple: #of peaks/ Area. The area is easy to calculate but how can i count the number of peaks? The peak curvature is a bit more complicated and have no idea how to calculate so I will leave the equation below. Also an estimate of the local gradient vector is provided. Any idea is welcomed I need to calculate the peak density of a 3D surface. The formula is simple: #of peaks/ Area. The area is easy to calculate but how can i count the number of peaks? The peak curvature is a bit more complicated and have no idea how to calculate so I will leave the equation below. Also an estimate of the local gradient vector is provided. Any idea is welcomed surface texture, image processing, metrology, feature parameters MATLAB Answers — New Questions
Calculate distance between two coordinates with depth
I need to do what’s in the title. I saw a file exchange about calculating the distance between two coordinates, but how would i do it considering the altitude? I have my data in latitude and longitude so i would need something to convert it first, i saw online and doing it one by one would take to longI need to do what’s in the title. I saw a file exchange about calculating the distance between two coordinates, but how would i do it considering the altitude? I have my data in latitude and longitude so i would need something to convert it first, i saw online and doing it one by one would take to long I need to do what’s in the title. I saw a file exchange about calculating the distance between two coordinates, but how would i do it considering the altitude? I have my data in latitude and longitude so i would need something to convert it first, i saw online and doing it one by one would take to long distance between to points MATLAB Answers — New Questions
error when using subcircuit2ssc for RohM SiC MOSFET
I tried to import spice file of RohM SiC MOSFET SCT4018KR and the following error occurs, the other spice file of RohM SiC MOSFET SCT3040KR is working fine.
>>SiC_4018
Error using spiceBase.findEnclosure
Delimiters must occur in pairs in .func r11(i,v)
{242.1m*ASINH(I*R12(V)/7.139)*exp((tj-t0)/-675.1*exp((tj-t0)/-36.83))+
20.4m*exp((tj-t0)/-836.2)*i*r12(v)}.I tried to import spice file of RohM SiC MOSFET SCT4018KR and the following error occurs, the other spice file of RohM SiC MOSFET SCT3040KR is working fine.
>>SiC_4018
Error using spiceBase.findEnclosure
Delimiters must occur in pairs in .func r11(i,v)
{242.1m*ASINH(I*R12(V)/7.139)*exp((tj-t0)/-675.1*exp((tj-t0)/-36.83))+
20.4m*exp((tj-t0)/-836.2)*i*r12(v)}. I tried to import spice file of RohM SiC MOSFET SCT4018KR and the following error occurs, the other spice file of RohM SiC MOSFET SCT3040KR is working fine.
>>SiC_4018
Error using spiceBase.findEnclosure
Delimiters must occur in pairs in .func r11(i,v)
{242.1m*ASINH(I*R12(V)/7.139)*exp((tj-t0)/-675.1*exp((tj-t0)/-36.83))+
20.4m*exp((tj-t0)/-836.2)*i*r12(v)}. sic mosfet model MATLAB Answers — New Questions