Category: Matlab
Category Archives: Matlab
simulink 如何封装成可脱离Matlab环境的可执行文件
我的simulink模型中有一部分是dymola建立的模型,通过FMU导入的,一部分是利用M文件编写的s-function用于matlab和REDIS数据库交换数据,这样的simulink模型,能否生存脱离matlab运行的可执行文件?如何操作?需要什么toolbox?我的simulink模型中有一部分是dymola建立的模型,通过FMU导入的,一部分是利用M文件编写的s-function用于matlab和REDIS数据库交换数据,这样的simulink模型,能否生存脱离matlab运行的可执行文件?如何操作?需要什么toolbox? 我的simulink模型中有一部分是dymola建立的模型,通过FMU导入的,一部分是利用M文件编写的s-function用于matlab和REDIS数据库交换数据,这样的simulink模型,能否生存脱离matlab运行的可执行文件?如何操作?需要什么toolbox? simulink 封装成可执行文件 MATLAB Answers — New Questions
Why is there a huge drop in the values of active and reactive power when the voltage of three phase voltage source is changed?
Hi Community,
I have modelled a grid using a programmable three phase voltage source and there are three loads attached to it. Model & Parameter file is attached. Each load is defined by the rated active and reactive powers (P& Q) as follows –
Load 1: Rated P = 25 kW; Rated Q = 5 kVA
Load 2: Rated P = 30 kW; rated Q = 10 kVA
Load 3: Rated P = 125 kW; rated Q = 10 kVA
The loads 2 and 3 are switched off at T = 2 secs and switched back on at T = 4 secs. I am also measuring the powers at each of the individual loads as well as the total power supplied by grid.
When I use the voltage source rating = 2300V, the P & Q values are nearly the same (but not exact match) as the above specified parameters.
When I use voltage source = 400V (with everything else remaining the same) there is a huge drop in the measured P & Q values and I am unable to follow why is this happening?
Q1) Why are the measured P&Q so low for V = 400V vs V = 2300V? Is there some limitation on the power this grid can deliver? If yes, then how is this being limited and how can I determine what is the maximum power rating of the load that can be connected across this grid source?
Q2) Additionally in the first scenario with 2300V why are the measured P&Q not the exact match of rated power of loads slightly lesser. I assume some power is lost in "losses" but I canot figure out where are these losses happening?Hi Community,
I have modelled a grid using a programmable three phase voltage source and there are three loads attached to it. Model & Parameter file is attached. Each load is defined by the rated active and reactive powers (P& Q) as follows –
Load 1: Rated P = 25 kW; Rated Q = 5 kVA
Load 2: Rated P = 30 kW; rated Q = 10 kVA
Load 3: Rated P = 125 kW; rated Q = 10 kVA
The loads 2 and 3 are switched off at T = 2 secs and switched back on at T = 4 secs. I am also measuring the powers at each of the individual loads as well as the total power supplied by grid.
When I use the voltage source rating = 2300V, the P & Q values are nearly the same (but not exact match) as the above specified parameters.
When I use voltage source = 400V (with everything else remaining the same) there is a huge drop in the measured P & Q values and I am unable to follow why is this happening?
Q1) Why are the measured P&Q so low for V = 400V vs V = 2300V? Is there some limitation on the power this grid can deliver? If yes, then how is this being limited and how can I determine what is the maximum power rating of the load that can be connected across this grid source?
Q2) Additionally in the first scenario with 2300V why are the measured P&Q not the exact match of rated power of loads slightly lesser. I assume some power is lost in "losses" but I canot figure out where are these losses happening? Hi Community,
I have modelled a grid using a programmable three phase voltage source and there are three loads attached to it. Model & Parameter file is attached. Each load is defined by the rated active and reactive powers (P& Q) as follows –
Load 1: Rated P = 25 kW; Rated Q = 5 kVA
Load 2: Rated P = 30 kW; rated Q = 10 kVA
Load 3: Rated P = 125 kW; rated Q = 10 kVA
The loads 2 and 3 are switched off at T = 2 secs and switched back on at T = 4 secs. I am also measuring the powers at each of the individual loads as well as the total power supplied by grid.
When I use the voltage source rating = 2300V, the P & Q values are nearly the same (but not exact match) as the above specified parameters.
When I use voltage source = 400V (with everything else remaining the same) there is a huge drop in the measured P & Q values and I am unable to follow why is this happening?
Q1) Why are the measured P&Q so low for V = 400V vs V = 2300V? Is there some limitation on the power this grid can deliver? If yes, then how is this being limited and how can I determine what is the maximum power rating of the load that can be connected across this grid source?
Q2) Additionally in the first scenario with 2300V why are the measured P&Q not the exact match of rated power of loads slightly lesser. I assume some power is lost in "losses" but I canot figure out where are these losses happening? grid, programmable voltage source, active power, reactive power, impedance, power measurement MATLAB Answers — New Questions
How do I extract images from a docx (word) file?
I am trying to extract images for processing from a docx (Word) file. How do I do this?I am trying to extract images for processing from a docx (Word) file. How do I do this? I am trying to extract images for processing from a docx (Word) file. How do I do this? docx, ms word, images MATLAB Answers — New Questions
Question about hair removal matlab code.
Hello all! I am doing a program about hair removal. And I found a code online but part of this code I couln’t understand. The final part(the loop part) was really confused me.
img_b is a binary image and after dilation we could get the img_b binary image, which the black part is skin and the white part is hair. Thus, the ‘for’ part in the final loop is to decide if this pixel is skin or hair, if the pixel is in the skin part then it keeps the same pixel value as the original image; if the pixel is in the hair part, then do ‘else’ and calculate it for removing hair.
So here comes the question, I do not understand the calculation part in ‘else’ and the meaning of parameter r.When I change the value of r into a bigger one, the running speed gets slower. So I wonder could anyone give me a guide about this part please?when I change the value of r into a bigger one, the running speed gets slower. Thank you!
Images are listed below: the first image is which we need to deal with and the second image is the processed image.
Updated on Mar. 7th 2019: Sorry guys forgot to put the otsu function. Already put it in case anyone need it.
if true
clear;
clc;
r=7;
se1_para = 3;
se2_para = 2;
img_old = imread(‘D:MATLAB1binpicsam3-2.jpg’);
figure(1),imshow(img_old);
[x,y,z] = size(img_old);
img = rgb2gray(img_old);
se1 = strel(‘disk’,se1_para);
img_c = imclose(img,se1)
figure(2), imshow(img_c,[]);
img_fur = double(img_c) – double(img);
figure(3),imshow(img_fur,[]);
[X Y]=meshgrid(1:x);
tt=(X-280).^2+(Y-280).^2<280^2;
thresh = otsu(img_fur(tt),sum(tt(:)));
img_b = (img_fur>thresh);
figure(4),imshow(img_b);
se2 = strel(‘disk’,se2_para);
img_b =imdilate(img_b,se2);
figure(5),imshow(img_b);
img_new = uint8(zeros(x,y,z));
for i = 1:x
for j = 1:y
if img_b(i,j) == false
img_new(i,j,:) = img_old(i,j,:);
else
ttt = img_old(max(1,i-r):min(i+r,x),max(j-r,1):min(j+r,y),:);
no_efficient_pix = cat(3,img_b(max(1,i-r):min(i+r,x),max(j-r,1):min(j+r,y)),not(tt(max(1,i-r):min(i+r,x),max(j-r,1):min(j+r,y))));
no_efficient_pix = any(no_efficient_pix,3);
ttt = ttt.*repmat(uint8(not(no_efficient_pix)),[1,1,3]);
efficient_pix_num = (2*r+1)^2-sum(no_efficient_pix(:));
img_new(i,j,:) = uint8(sum(sum(ttt))./efficient_pix_num);
end
end
end
figure(6),imshow(img_new,[]);
end
function thresh = otsu(data,pix_num)
img_var = zeros(256,1);
for i=1:256
w0 = sum(sum(data<=i-1))./pix_num;
w1 = 1-w0;
u0 = sum(sum(data.*double(data<=i-1)))./(w0*pix_num);
u1 = sum(sum(data.*double(data>i-1)))./(w1*pix_num);
img_var(i) = w0.*w1.*((u0-u1).^2);
end
[~,I] = max(img_var);
thresh = I-1;
endHello all! I am doing a program about hair removal. And I found a code online but part of this code I couln’t understand. The final part(the loop part) was really confused me.
img_b is a binary image and after dilation we could get the img_b binary image, which the black part is skin and the white part is hair. Thus, the ‘for’ part in the final loop is to decide if this pixel is skin or hair, if the pixel is in the skin part then it keeps the same pixel value as the original image; if the pixel is in the hair part, then do ‘else’ and calculate it for removing hair.
So here comes the question, I do not understand the calculation part in ‘else’ and the meaning of parameter r.When I change the value of r into a bigger one, the running speed gets slower. So I wonder could anyone give me a guide about this part please?when I change the value of r into a bigger one, the running speed gets slower. Thank you!
Images are listed below: the first image is which we need to deal with and the second image is the processed image.
Updated on Mar. 7th 2019: Sorry guys forgot to put the otsu function. Already put it in case anyone need it.
if true
clear;
clc;
r=7;
se1_para = 3;
se2_para = 2;
img_old = imread(‘D:MATLAB1binpicsam3-2.jpg’);
figure(1),imshow(img_old);
[x,y,z] = size(img_old);
img = rgb2gray(img_old);
se1 = strel(‘disk’,se1_para);
img_c = imclose(img,se1)
figure(2), imshow(img_c,[]);
img_fur = double(img_c) – double(img);
figure(3),imshow(img_fur,[]);
[X Y]=meshgrid(1:x);
tt=(X-280).^2+(Y-280).^2<280^2;
thresh = otsu(img_fur(tt),sum(tt(:)));
img_b = (img_fur>thresh);
figure(4),imshow(img_b);
se2 = strel(‘disk’,se2_para);
img_b =imdilate(img_b,se2);
figure(5),imshow(img_b);
img_new = uint8(zeros(x,y,z));
for i = 1:x
for j = 1:y
if img_b(i,j) == false
img_new(i,j,:) = img_old(i,j,:);
else
ttt = img_old(max(1,i-r):min(i+r,x),max(j-r,1):min(j+r,y),:);
no_efficient_pix = cat(3,img_b(max(1,i-r):min(i+r,x),max(j-r,1):min(j+r,y)),not(tt(max(1,i-r):min(i+r,x),max(j-r,1):min(j+r,y))));
no_efficient_pix = any(no_efficient_pix,3);
ttt = ttt.*repmat(uint8(not(no_efficient_pix)),[1,1,3]);
efficient_pix_num = (2*r+1)^2-sum(no_efficient_pix(:));
img_new(i,j,:) = uint8(sum(sum(ttt))./efficient_pix_num);
end
end
end
figure(6),imshow(img_new,[]);
end
function thresh = otsu(data,pix_num)
img_var = zeros(256,1);
for i=1:256
w0 = sum(sum(data<=i-1))./pix_num;
w1 = 1-w0;
u0 = sum(sum(data.*double(data<=i-1)))./(w0*pix_num);
u1 = sum(sum(data.*double(data>i-1)))./(w1*pix_num);
img_var(i) = w0.*w1.*((u0-u1).^2);
end
[~,I] = max(img_var);
thresh = I-1;
end Hello all! I am doing a program about hair removal. And I found a code online but part of this code I couln’t understand. The final part(the loop part) was really confused me.
img_b is a binary image and after dilation we could get the img_b binary image, which the black part is skin and the white part is hair. Thus, the ‘for’ part in the final loop is to decide if this pixel is skin or hair, if the pixel is in the skin part then it keeps the same pixel value as the original image; if the pixel is in the hair part, then do ‘else’ and calculate it for removing hair.
So here comes the question, I do not understand the calculation part in ‘else’ and the meaning of parameter r.When I change the value of r into a bigger one, the running speed gets slower. So I wonder could anyone give me a guide about this part please?when I change the value of r into a bigger one, the running speed gets slower. Thank you!
Images are listed below: the first image is which we need to deal with and the second image is the processed image.
Updated on Mar. 7th 2019: Sorry guys forgot to put the otsu function. Already put it in case anyone need it.
if true
clear;
clc;
r=7;
se1_para = 3;
se2_para = 2;
img_old = imread(‘D:MATLAB1binpicsam3-2.jpg’);
figure(1),imshow(img_old);
[x,y,z] = size(img_old);
img = rgb2gray(img_old);
se1 = strel(‘disk’,se1_para);
img_c = imclose(img,se1)
figure(2), imshow(img_c,[]);
img_fur = double(img_c) – double(img);
figure(3),imshow(img_fur,[]);
[X Y]=meshgrid(1:x);
tt=(X-280).^2+(Y-280).^2<280^2;
thresh = otsu(img_fur(tt),sum(tt(:)));
img_b = (img_fur>thresh);
figure(4),imshow(img_b);
se2 = strel(‘disk’,se2_para);
img_b =imdilate(img_b,se2);
figure(5),imshow(img_b);
img_new = uint8(zeros(x,y,z));
for i = 1:x
for j = 1:y
if img_b(i,j) == false
img_new(i,j,:) = img_old(i,j,:);
else
ttt = img_old(max(1,i-r):min(i+r,x),max(j-r,1):min(j+r,y),:);
no_efficient_pix = cat(3,img_b(max(1,i-r):min(i+r,x),max(j-r,1):min(j+r,y)),not(tt(max(1,i-r):min(i+r,x),max(j-r,1):min(j+r,y))));
no_efficient_pix = any(no_efficient_pix,3);
ttt = ttt.*repmat(uint8(not(no_efficient_pix)),[1,1,3]);
efficient_pix_num = (2*r+1)^2-sum(no_efficient_pix(:));
img_new(i,j,:) = uint8(sum(sum(ttt))./efficient_pix_num);
end
end
end
figure(6),imshow(img_new,[]);
end
function thresh = otsu(data,pix_num)
img_var = zeros(256,1);
for i=1:256
w0 = sum(sum(data<=i-1))./pix_num;
w1 = 1-w0;
u0 = sum(sum(data.*double(data<=i-1)))./(w0*pix_num);
u1 = sum(sum(data.*double(data>i-1)))./(w1*pix_num);
img_var(i) = w0.*w1.*((u0-u1).^2);
end
[~,I] = max(img_var);
thresh = I-1;
end hair removal MATLAB Answers — New Questions
Entering the mechanical and volumetric efficiency of a fixed displacement pump
I want to enter the mechanical and volumetric efficiency values of a fixed displacement pump in a hydraulic system within SIMScape MATLAB. I have activated the mechanical and volumetric efficiency ports from the pump’s mass variables, but I have not found a way to enter the efficiency values into those ports… I need help to adjust the efficiency values for the pumpI want to enter the mechanical and volumetric efficiency values of a fixed displacement pump in a hydraulic system within SIMScape MATLAB. I have activated the mechanical and volumetric efficiency ports from the pump’s mass variables, but I have not found a way to enter the efficiency values into those ports… I need help to adjust the efficiency values for the pump I want to enter the mechanical and volumetric efficiency values of a fixed displacement pump in a hydraulic system within SIMScape MATLAB. I have activated the mechanical and volumetric efficiency ports from the pump’s mass variables, but I have not found a way to enter the efficiency values into those ports… I need help to adjust the efficiency values for the pump efficiency control MATLAB Answers — New Questions
CRS mismatch or I do not know
I am working onI am working on I am working on notag MATLAB Answers — New Questions
Error evaluating parameter ‘Mass’ , Unable to resolve the name smiData.Solid.
I am getting error when i am, importing assembly from the invent. I am having error at the joints and also the parts imported doesn’t import data regarding inertia or geometry. When i run the simulation, I am getting this error
Caused by:
Error evaluating parameter ‘Mass’ in
Unable to resolve the name smiData.Solid.
Error evaluating parameter ‘CenterOfMass’ in ‘NewTestAssembly
Thank you
Sorry i have to hide few names due to some technical issueI am getting error when i am, importing assembly from the invent. I am having error at the joints and also the parts imported doesn’t import data regarding inertia or geometry. When i run the simulation, I am getting this error
Caused by:
Error evaluating parameter ‘Mass’ in
Unable to resolve the name smiData.Solid.
Error evaluating parameter ‘CenterOfMass’ in ‘NewTestAssembly
Thank you
Sorry i have to hide few names due to some technical issue I am getting error when i am, importing assembly from the invent. I am having error at the joints and also the parts imported doesn’t import data regarding inertia or geometry. When i run the simulation, I am getting this error
Caused by:
Error evaluating parameter ‘Mass’ in
Unable to resolve the name smiData.Solid.
Error evaluating parameter ‘CenterOfMass’ in ‘NewTestAssembly
Thank you
Sorry i have to hide few names due to some technical issue error evaluating, mass MATLAB Answers — New Questions
error when using segment function
I get these errors when running this snippet of code that references another script (script attached as a matlab file)
[filt_in, data_in_segs_corrected, segment_params]=segment_filt_v2(data_to_segment,[],[],params.genome_build);
params.segment_params=segment_params;
Warning: The data contains more columns (number of channels) than rows (number of samples). Check that the data is not transposed inadvertently.
> In ctrlMsgUtils.warning (line 25)
In segment (line 76)
In segment_filt_v2>seg_fun (line 145)
In segment_filt_v2 (line 101)
Unrecognized function or variable ‘jmax’.
Error in segment (line 236)
hh=hist(:,jmax);
Error in segment_filt_v2>seg_fun (line 145)
thm=segment([data_in(idx+1:end),ones(length(data_in)-idx,1)],[0 1 1],R2);
Error in segment_filt_v2 (line 101)
data_in_segs_corrected{Chr}(in,c-4)=seg_fun(Data{Chr}(in,c), R2);I get these errors when running this snippet of code that references another script (script attached as a matlab file)
[filt_in, data_in_segs_corrected, segment_params]=segment_filt_v2(data_to_segment,[],[],params.genome_build);
params.segment_params=segment_params;
Warning: The data contains more columns (number of channels) than rows (number of samples). Check that the data is not transposed inadvertently.
> In ctrlMsgUtils.warning (line 25)
In segment (line 76)
In segment_filt_v2>seg_fun (line 145)
In segment_filt_v2 (line 101)
Unrecognized function or variable ‘jmax’.
Error in segment (line 236)
hh=hist(:,jmax);
Error in segment_filt_v2>seg_fun (line 145)
thm=segment([data_in(idx+1:end),ones(length(data_in)-idx,1)],[0 1 1],R2);
Error in segment_filt_v2 (line 101)
data_in_segs_corrected{Chr}(in,c-4)=seg_fun(Data{Chr}(in,c), R2); I get these errors when running this snippet of code that references another script (script attached as a matlab file)
[filt_in, data_in_segs_corrected, segment_params]=segment_filt_v2(data_to_segment,[],[],params.genome_build);
params.segment_params=segment_params;
Warning: The data contains more columns (number of channels) than rows (number of samples). Check that the data is not transposed inadvertently.
> In ctrlMsgUtils.warning (line 25)
In segment (line 76)
In segment_filt_v2>seg_fun (line 145)
In segment_filt_v2 (line 101)
Unrecognized function or variable ‘jmax’.
Error in segment (line 236)
hh=hist(:,jmax);
Error in segment_filt_v2>seg_fun (line 145)
thm=segment([data_in(idx+1:end),ones(length(data_in)-idx,1)],[0 1 1],R2);
Error in segment_filt_v2 (line 101)
data_in_segs_corrected{Chr}(in,c-4)=seg_fun(Data{Chr}(in,c), R2); segment MATLAB Answers — New Questions
trying to use the command hinfsyn on a rotary inverted pendulum for stabilization analysis
Hello
I am trying to follow this paper
http://ietresearch.onlinelibrary.wiley.com/doi/epdf/10.1049/tje2.12078
I have made following code for making the system looking like this
The code is given below
A=[0 0 1 0;
0 0 0 1;
0 39.32 -14.52 0;
0 81.78 -13.98 0;];
B=[0;0;25.54;24.59];
C=[1 0 0 0;
0 1 0 0];
D=[0;0;];
sys=ss(A,B,C,D);
sys.InputName={‘u’};
sys.OutputName={‘theta’,’alpha’};
s=tf(‘s’);
Wact=0.002*(s+0.01)/(s+10);
Wact.u=’u’; Wact.y=’e1′;
Wn1=ss(0.05);
Wn1.u=’d1′; Wn1.y=’wn1′;
Wn2=ss(0.0275);
Wn2.u=’d2′; Wn2.y=’wn2′;
Wx1=151.5/(s+50.5);
Wx1.u=’theta’; Wx1.y=’e2′;
Wx2=202/(s+50.5);
Wx2.u=’alpha’; Wx2.y=’e3′;
sdmeas=sumblk(‘y1 = theta+wn1’);
abmeas=sumblk(‘y2 = alpha+wn2’);
ICinputs={‘d1′,’d2′,’u’};
ICoutputs={‘e1′,’e2′,’e3′,’y1′,’y2’};
qsys=connect(sys,Wact,Wn1,Wn2,Wx1,Wx2,sdmeas,abmeas,ICinputs,ICoutputs);
When I am running the command hinfsyn I get following gamma
[~,~,gamma]=hinfsyn(qsys,2,1)
while in the paper they have
gamma=0.6951 in section 3.1 H-infinty controll. Where is my mistake or any solution to get the same answer as in the paper ?
Thanks for all answers
Tor Erik HaavikHello
I am trying to follow this paper
http://ietresearch.onlinelibrary.wiley.com/doi/epdf/10.1049/tje2.12078
I have made following code for making the system looking like this
The code is given below
A=[0 0 1 0;
0 0 0 1;
0 39.32 -14.52 0;
0 81.78 -13.98 0;];
B=[0;0;25.54;24.59];
C=[1 0 0 0;
0 1 0 0];
D=[0;0;];
sys=ss(A,B,C,D);
sys.InputName={‘u’};
sys.OutputName={‘theta’,’alpha’};
s=tf(‘s’);
Wact=0.002*(s+0.01)/(s+10);
Wact.u=’u’; Wact.y=’e1′;
Wn1=ss(0.05);
Wn1.u=’d1′; Wn1.y=’wn1′;
Wn2=ss(0.0275);
Wn2.u=’d2′; Wn2.y=’wn2′;
Wx1=151.5/(s+50.5);
Wx1.u=’theta’; Wx1.y=’e2′;
Wx2=202/(s+50.5);
Wx2.u=’alpha’; Wx2.y=’e3′;
sdmeas=sumblk(‘y1 = theta+wn1’);
abmeas=sumblk(‘y2 = alpha+wn2’);
ICinputs={‘d1′,’d2′,’u’};
ICoutputs={‘e1′,’e2′,’e3′,’y1′,’y2’};
qsys=connect(sys,Wact,Wn1,Wn2,Wx1,Wx2,sdmeas,abmeas,ICinputs,ICoutputs);
When I am running the command hinfsyn I get following gamma
[~,~,gamma]=hinfsyn(qsys,2,1)
while in the paper they have
gamma=0.6951 in section 3.1 H-infinty controll. Where is my mistake or any solution to get the same answer as in the paper ?
Thanks for all answers
Tor Erik Haavik Hello
I am trying to follow this paper
http://ietresearch.onlinelibrary.wiley.com/doi/epdf/10.1049/tje2.12078
I have made following code for making the system looking like this
The code is given below
A=[0 0 1 0;
0 0 0 1;
0 39.32 -14.52 0;
0 81.78 -13.98 0;];
B=[0;0;25.54;24.59];
C=[1 0 0 0;
0 1 0 0];
D=[0;0;];
sys=ss(A,B,C,D);
sys.InputName={‘u’};
sys.OutputName={‘theta’,’alpha’};
s=tf(‘s’);
Wact=0.002*(s+0.01)/(s+10);
Wact.u=’u’; Wact.y=’e1′;
Wn1=ss(0.05);
Wn1.u=’d1′; Wn1.y=’wn1′;
Wn2=ss(0.0275);
Wn2.u=’d2′; Wn2.y=’wn2′;
Wx1=151.5/(s+50.5);
Wx1.u=’theta’; Wx1.y=’e2′;
Wx2=202/(s+50.5);
Wx2.u=’alpha’; Wx2.y=’e3′;
sdmeas=sumblk(‘y1 = theta+wn1’);
abmeas=sumblk(‘y2 = alpha+wn2’);
ICinputs={‘d1′,’d2′,’u’};
ICoutputs={‘e1′,’e2′,’e3′,’y1′,’y2’};
qsys=connect(sys,Wact,Wn1,Wn2,Wx1,Wx2,sdmeas,abmeas,ICinputs,ICoutputs);
When I am running the command hinfsyn I get following gamma
[~,~,gamma]=hinfsyn(qsys,2,1)
while in the paper they have
gamma=0.6951 in section 3.1 H-infinty controll. Where is my mistake or any solution to get the same answer as in the paper ?
Thanks for all answers
Tor Erik Haavik matlab code, control system, roboust control system MATLAB Answers — New Questions
tiledlayout doesn’t behave as it should
Followed the example of https://www.mathworks.com/help/matlab/ref/tiledlayout.html with ‘TileSpacing’, ‘none’option. The output is as image shown with huge gap in rows.
row = 8;
col = 5;
figure
tiledlayout(row,col,’TileSpacing’,’none’);
for ns = 1:nums
nexttile
imagesc(images(:,:,ns));colormap gray;axis off; axis square
endFollowed the example of https://www.mathworks.com/help/matlab/ref/tiledlayout.html with ‘TileSpacing’, ‘none’option. The output is as image shown with huge gap in rows.
row = 8;
col = 5;
figure
tiledlayout(row,col,’TileSpacing’,’none’);
for ns = 1:nums
nexttile
imagesc(images(:,:,ns));colormap gray;axis off; axis square
end Followed the example of https://www.mathworks.com/help/matlab/ref/tiledlayout.html with ‘TileSpacing’, ‘none’option. The output is as image shown with huge gap in rows.
row = 8;
col = 5;
figure
tiledlayout(row,col,’TileSpacing’,’none’);
for ns = 1:nums
nexttile
imagesc(images(:,:,ns));colormap gray;axis off; axis square
end tiledlayout, matlab MATLAB Answers — New Questions
How do I reconnect USB serial that gets lost programatically.
MatLab R2024b using AppDesigner on Windows 10 Enterprise
My GUI app connects to an Arduino which sometimes looses it’s connection or reboots itself.
I’m trying to detect when connection is lost and reconnect, but after getting an error message in the Command Window:
Unable to detect connection to the serialport device. Ensure that the device is plugged in and create a new serialport object.
My program (at least interacting with it in the CW is hung until I Ctrl-C.
I have set a dummy breakpoint so I can see variables from the Command Window (It doesn’t seem to know anything about my app until I break, but at least the program still runs after the break button is pushed)
So here’s what happens in CW with my comments added in bold and extra blank lines removed:
2513 pause(0.5); Pressed the Break Button
K>> app.PicoCom Look at my Serial Port connection
ans =
Serialport with properties:
Port: "COM11"
BaudRate: 57600
NumBytesAvailable: 0
etc… Now I reboot my Arduino and get:
Unable to detect connection to the serialport device. Ensure that the device is plugged in and create a new serialport object.
K>> app.PicoCom Try to look at serial port (or do ANYTHING)
[CW hangs until I hit Ctrl-C – WHY?
Operation terminated by user during MouseOdor61/RunOneTrial (line 1131)
In MouseOdor61/DoSession (line 1238)
etc
In matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 60)
newCallback = @(source, event)executeCallback(ams, …
^^^^^^^^^^^^^^^^^^^^^^^^
Interrupt while evaluating Button PrivateButtonPushedFcn.
ans =
Serialport with properties:
In
‘testmeaslib:CustomDisplay:PropertyWarning’,
data type supplied is incorrect for parameter
{0}.
Now I can try to see the handle again.
K>> app.PicoCom
ans =
Serialport with properties:
In
‘testmeaslib:CustomDisplay:PropertyWarning’,
data type supplied is incorrect for
parameter {0}.
Not very helpful. At this point I can see:
K>> serialportlist()
ans =
1×2 string array
"COM1" "COM11"
To recover this seems to work:
K>> delete(app.PicoCom)
Let’s check
K>> app.PicoCom
ans =
handle to deleted Serialport
Reconnect
K>> app.PicoCom = serialport
[ shows every object in app! If I don’t add the ;]
K>> app.PicoCom
ans =
Serialport with properties:
Port: "COM11"
BaudRate: 57600
Tag: ""
NumBytesAvailable: 0
OK, it’s back, all I need to add, it appears is the callback
K>> configureCallback(app.PicoCom,"terminator",@app.PicoInput)
I’ve tried putting things in my callback for input (like try … catch) but it never gets there.
It’s stuck in matlab.apps.AppBase not my code
I also added checks in the output routine to the Arduino, but it doesn’t seem to be helpful. That thread is stuck! I can press another button in the app the forces a reconnect but I want it to happen without user intervention.
How can I detect and trap the loss of COM in my program? (Obviously I want to stop the Pico from rebooting, but meanwhile my users need some decent work around).MatLab R2024b using AppDesigner on Windows 10 Enterprise
My GUI app connects to an Arduino which sometimes looses it’s connection or reboots itself.
I’m trying to detect when connection is lost and reconnect, but after getting an error message in the Command Window:
Unable to detect connection to the serialport device. Ensure that the device is plugged in and create a new serialport object.
My program (at least interacting with it in the CW is hung until I Ctrl-C.
I have set a dummy breakpoint so I can see variables from the Command Window (It doesn’t seem to know anything about my app until I break, but at least the program still runs after the break button is pushed)
So here’s what happens in CW with my comments added in bold and extra blank lines removed:
2513 pause(0.5); Pressed the Break Button
K>> app.PicoCom Look at my Serial Port connection
ans =
Serialport with properties:
Port: "COM11"
BaudRate: 57600
NumBytesAvailable: 0
etc… Now I reboot my Arduino and get:
Unable to detect connection to the serialport device. Ensure that the device is plugged in and create a new serialport object.
K>> app.PicoCom Try to look at serial port (or do ANYTHING)
[CW hangs until I hit Ctrl-C – WHY?
Operation terminated by user during MouseOdor61/RunOneTrial (line 1131)
In MouseOdor61/DoSession (line 1238)
etc
In matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 60)
newCallback = @(source, event)executeCallback(ams, …
^^^^^^^^^^^^^^^^^^^^^^^^
Interrupt while evaluating Button PrivateButtonPushedFcn.
ans =
Serialport with properties:
In
‘testmeaslib:CustomDisplay:PropertyWarning’,
data type supplied is incorrect for parameter
{0}.
Now I can try to see the handle again.
K>> app.PicoCom
ans =
Serialport with properties:
In
‘testmeaslib:CustomDisplay:PropertyWarning’,
data type supplied is incorrect for
parameter {0}.
Not very helpful. At this point I can see:
K>> serialportlist()
ans =
1×2 string array
"COM1" "COM11"
To recover this seems to work:
K>> delete(app.PicoCom)
Let’s check
K>> app.PicoCom
ans =
handle to deleted Serialport
Reconnect
K>> app.PicoCom = serialport
[ shows every object in app! If I don’t add the ;]
K>> app.PicoCom
ans =
Serialport with properties:
Port: "COM11"
BaudRate: 57600
Tag: ""
NumBytesAvailable: 0
OK, it’s back, all I need to add, it appears is the callback
K>> configureCallback(app.PicoCom,"terminator",@app.PicoInput)
I’ve tried putting things in my callback for input (like try … catch) but it never gets there.
It’s stuck in matlab.apps.AppBase not my code
I also added checks in the output routine to the Arduino, but it doesn’t seem to be helpful. That thread is stuck! I can press another button in the app the forces a reconnect but I want it to happen without user intervention.
How can I detect and trap the loss of COM in my program? (Obviously I want to stop the Pico from rebooting, but meanwhile my users need some decent work around). MatLab R2024b using AppDesigner on Windows 10 Enterprise
My GUI app connects to an Arduino which sometimes looses it’s connection or reboots itself.
I’m trying to detect when connection is lost and reconnect, but after getting an error message in the Command Window:
Unable to detect connection to the serialport device. Ensure that the device is plugged in and create a new serialport object.
My program (at least interacting with it in the CW is hung until I Ctrl-C.
I have set a dummy breakpoint so I can see variables from the Command Window (It doesn’t seem to know anything about my app until I break, but at least the program still runs after the break button is pushed)
So here’s what happens in CW with my comments added in bold and extra blank lines removed:
2513 pause(0.5); Pressed the Break Button
K>> app.PicoCom Look at my Serial Port connection
ans =
Serialport with properties:
Port: "COM11"
BaudRate: 57600
NumBytesAvailable: 0
etc… Now I reboot my Arduino and get:
Unable to detect connection to the serialport device. Ensure that the device is plugged in and create a new serialport object.
K>> app.PicoCom Try to look at serial port (or do ANYTHING)
[CW hangs until I hit Ctrl-C – WHY?
Operation terminated by user during MouseOdor61/RunOneTrial (line 1131)
In MouseOdor61/DoSession (line 1238)
etc
In matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 60)
newCallback = @(source, event)executeCallback(ams, …
^^^^^^^^^^^^^^^^^^^^^^^^
Interrupt while evaluating Button PrivateButtonPushedFcn.
ans =
Serialport with properties:
In
‘testmeaslib:CustomDisplay:PropertyWarning’,
data type supplied is incorrect for parameter
{0}.
Now I can try to see the handle again.
K>> app.PicoCom
ans =
Serialport with properties:
In
‘testmeaslib:CustomDisplay:PropertyWarning’,
data type supplied is incorrect for
parameter {0}.
Not very helpful. At this point I can see:
K>> serialportlist()
ans =
1×2 string array
"COM1" "COM11"
To recover this seems to work:
K>> delete(app.PicoCom)
Let’s check
K>> app.PicoCom
ans =
handle to deleted Serialport
Reconnect
K>> app.PicoCom = serialport
[ shows every object in app! If I don’t add the ;]
K>> app.PicoCom
ans =
Serialport with properties:
Port: "COM11"
BaudRate: 57600
Tag: ""
NumBytesAvailable: 0
OK, it’s back, all I need to add, it appears is the callback
K>> configureCallback(app.PicoCom,"terminator",@app.PicoInput)
I’ve tried putting things in my callback for input (like try … catch) but it never gets there.
It’s stuck in matlab.apps.AppBase not my code
I also added checks in the output routine to the Arduino, but it doesn’t seem to be helpful. That thread is stuck! I can press another button in the app the forces a reconnect but I want it to happen without user intervention.
How can I detect and trap the loss of COM in my program? (Obviously I want to stop the Pico from rebooting, but meanwhile my users need some decent work around). reconnect usb MATLAB Answers — New Questions
Matlab editor has low quality compared to simulink and other windows on Arch linux
Using matlab on arch linux leads to very low quality graphics, I tried following "matlab support high dpi screends on linux", however it did not fix my issue
I tried changing the fonts to make it more readible, but that doesn’t completely work.
Even stranger, the editor seems perfectly fine, it’s just everything else that is low quality
Simulink looks much nicer, and it is readable, might have to zoom in to compare the two pictures
Could the issue be that I am using wayland instead of xorg, which is why the other tutorial wasn’t working?Using matlab on arch linux leads to very low quality graphics, I tried following "matlab support high dpi screends on linux", however it did not fix my issue
I tried changing the fonts to make it more readible, but that doesn’t completely work.
Even stranger, the editor seems perfectly fine, it’s just everything else that is low quality
Simulink looks much nicer, and it is readable, might have to zoom in to compare the two pictures
Could the issue be that I am using wayland instead of xorg, which is why the other tutorial wasn’t working? Using matlab on arch linux leads to very low quality graphics, I tried following "matlab support high dpi screends on linux", however it did not fix my issue
I tried changing the fonts to make it more readible, but that doesn’t completely work.
Even stranger, the editor seems perfectly fine, it’s just everything else that is low quality
Simulink looks much nicer, and it is readable, might have to zoom in to compare the two pictures
Could the issue be that I am using wayland instead of xorg, which is why the other tutorial wasn’t working? linux, display MATLAB Answers — New Questions
MATLAB Coder Onramp Issue – Section 4 Call C Code from MATLAB
Hi all,
I am currently running through some of the learning materails online for both MATLAB and Simulink. I have started going over the MATLAB Coder Onramp which goes through the mecanisms for generating C code from MATLAB. This is using the website based version of the courses and as such the MATLAB environement is within the web browser itself.
However, I seem to be stuck at section 4 "Call C Code From MATLAB – Verify Generated Code". The task asks the following,
To generate a MEX function, you don’t need to specify a configuration because the codegen function generates MEX by default.
codegen fcn -args {var} -report
If your function has input arguments and you want a code generation report, you can continue using ‑args and ‑report.
Task
Generate MEX code for the detectpH function. Use I2 as the example input.
The code may take up to ten seconds to generate.
Now I have added my result and compared this to the "See Solution" and it is the same
codegen detectpH -args {I2} -report
However, when I select Submit, I get an error using Codegen. I have cleared my entry, closed and reopened the course and even copied and pasted the result from the "See Solution" too to make sure there were no spelling mistakes but still no luck.
I am wondering if this is an issue to do with the in browser environment perhaps?
I did have issues with generating the C code earlier in the course, but as the training allowed me to continune, I assumed this was going to be dealt with in the next sections.
Hopefully I am doing something daft and its a simple fix.
I have attached the Build Log for additional infromation.
Thanks,
JasonHi all,
I am currently running through some of the learning materails online for both MATLAB and Simulink. I have started going over the MATLAB Coder Onramp which goes through the mecanisms for generating C code from MATLAB. This is using the website based version of the courses and as such the MATLAB environement is within the web browser itself.
However, I seem to be stuck at section 4 "Call C Code From MATLAB – Verify Generated Code". The task asks the following,
To generate a MEX function, you don’t need to specify a configuration because the codegen function generates MEX by default.
codegen fcn -args {var} -report
If your function has input arguments and you want a code generation report, you can continue using ‑args and ‑report.
Task
Generate MEX code for the detectpH function. Use I2 as the example input.
The code may take up to ten seconds to generate.
Now I have added my result and compared this to the "See Solution" and it is the same
codegen detectpH -args {I2} -report
However, when I select Submit, I get an error using Codegen. I have cleared my entry, closed and reopened the course and even copied and pasted the result from the "See Solution" too to make sure there were no spelling mistakes but still no luck.
I am wondering if this is an issue to do with the in browser environment perhaps?
I did have issues with generating the C code earlier in the course, but as the training allowed me to continune, I assumed this was going to be dealt with in the next sections.
Hopefully I am doing something daft and its a simple fix.
I have attached the Build Log for additional infromation.
Thanks,
Jason Hi all,
I am currently running through some of the learning materails online for both MATLAB and Simulink. I have started going over the MATLAB Coder Onramp which goes through the mecanisms for generating C code from MATLAB. This is using the website based version of the courses and as such the MATLAB environement is within the web browser itself.
However, I seem to be stuck at section 4 "Call C Code From MATLAB – Verify Generated Code". The task asks the following,
To generate a MEX function, you don’t need to specify a configuration because the codegen function generates MEX by default.
codegen fcn -args {var} -report
If your function has input arguments and you want a code generation report, you can continue using ‑args and ‑report.
Task
Generate MEX code for the detectpH function. Use I2 as the example input.
The code may take up to ten seconds to generate.
Now I have added my result and compared this to the "See Solution" and it is the same
codegen detectpH -args {I2} -report
However, when I select Submit, I get an error using Codegen. I have cleared my entry, closed and reopened the course and even copied and pasted the result from the "See Solution" too to make sure there were no spelling mistakes but still no luck.
I am wondering if this is an issue to do with the in browser environment perhaps?
I did have issues with generating the C code earlier in the course, but as the training allowed me to continune, I assumed this was going to be dealt with in the next sections.
Hopefully I am doing something daft and its a simple fix.
I have attached the Build Log for additional infromation.
Thanks,
Jason onramp, matlab coder, codegen, code generation MATLAB Answers — New Questions
I want to use a low-pass filter to cut off frequencies above the cutoff frequency.
I am trying to cut frequencies above the cutoff frequency using the lowpass function, but it is not working.
I am trying to cut the frequency by applying a lowpass filter to the tunnel current z multiplied by the reference signal sin(wt).
The cutoff frequency is set at 500 Hz, so when I graph the FFT, the peaks at frequencies higher than 500 Hz should disappear, but they do not.
%Parameter Setting
pixel_image = 256; %Input the number of pixels in the image obtained by raster scanning (input 2^n)
dr = 1/(2*sqrt(3)); %Enter dither circle radius [grid].
a_fast_grid = 10; %fast axis scanning range [grid]
a_slow_grid = 10; %Slow axis scanning range [grid]
fm=5000; %Dither circle modulation frequency [Hz]
fs= fm*240 ; %Sampling frequency [Hz]
f_fast = 10.2; %Input scanning frequency [Hz] (1 line scanning count in 1[s])
start_point_x = 0; %Input x-coordinate of scanning start point (input 1 if you want to move by 1[grid])
start_point_y = 0; %Input y-coordinate of scanning start point (input 1 if you want to move by 1[grid])
%Parameter setting for fast-axis triangular wave
amplitude_fast = a_fast_grid/2; %fast axis amplitude
%Parameter setting for slow-axis triangular wave
amplitude_slow = a_slow_grid/2; %slow axis amplitude
f_slow = (f_fast)/(2*pixel_image); %Slow axis triangular wave frequency
% Generation of time vectors
total_time=256/f_fast; %Total Scan Time
t = linspace(0, total_time, fs * total_time);
x_raster = start_point_x + amplitude_fast*(2/pi)*acos(cos(2*pi*f_fast*t));
y_raster = start_point_y + amplitude_slow*(2/pi)*acos(cos(2*pi*f_slow*t));
x_dither = dr*cos(2*pi*fm*t);
y_dither = dr*sin(2*pi*fm*t);
x = x_raster + x_dither;
y = y_raster + y_dither;
z1 = cos(2*pi*((x-y)/(sqrt(3))));
z2 = cos(2*pi*(2*y/(sqrt(3))));
z3 = cos(2*pi*((x+y)/(sqrt(3))));
z = (z1 + z2 + z3);
%Reference Signal Creation
w = 2*pi*fm ;
phi = 0 ;
reference_signal = sin(w*t+phi) ;
%Mixing signal creation
mixising_signal = z.* reference_signal ;
%Applying a low-pass filter
f_cutoff = 500 ; %Cutoff frequency [Hz] setting
lowpass_signal = lowpass(mixising_signal,f_cutoff,fs) ;
%The result of FFT.——————————————-
n = length(t); % Number of samples
f = (0:n-1)*(fs/n); % Frequency axis [Hz]
half_n = floor(n/2); % Half of data
fft_z = abs(fft(z) / n);
fft_mixising_signal = abs(fft(mixising_signal) / n);
fft_lowpass_signal = abs(fft(lowpass_signal) / n);
figure;
tiledlayout(3,1)
nexttile
plot(f(1:half_n), fft_z(1:half_n));
title(‘FFT of tunnel current’); xlabel(‘Frequency [Hz]’); ylabel(‘Amplitude’);
xlim([0 20000]),ylim([0 0.3]);
nexttile
plot(f(1:half_n), fft_mixising_signal(1:half_n));
title(‘FFT of mixing signal’); xlabel(‘Frequency [Hz]’); ylabel(‘Amplitude’);
xlim([0 20000]),ylim([0 0.3]);
nexttile
plot(f(1:half_n), fft_lowpass_signal(1:half_n));
title(‘FFT after applying low-pass’); xlabel(‘Frequency [Hz]’); ylabel(‘Amplitude’);
xlim([0 20000]),ylim([0 0.3]);I am trying to cut frequencies above the cutoff frequency using the lowpass function, but it is not working.
I am trying to cut the frequency by applying a lowpass filter to the tunnel current z multiplied by the reference signal sin(wt).
The cutoff frequency is set at 500 Hz, so when I graph the FFT, the peaks at frequencies higher than 500 Hz should disappear, but they do not.
%Parameter Setting
pixel_image = 256; %Input the number of pixels in the image obtained by raster scanning (input 2^n)
dr = 1/(2*sqrt(3)); %Enter dither circle radius [grid].
a_fast_grid = 10; %fast axis scanning range [grid]
a_slow_grid = 10; %Slow axis scanning range [grid]
fm=5000; %Dither circle modulation frequency [Hz]
fs= fm*240 ; %Sampling frequency [Hz]
f_fast = 10.2; %Input scanning frequency [Hz] (1 line scanning count in 1[s])
start_point_x = 0; %Input x-coordinate of scanning start point (input 1 if you want to move by 1[grid])
start_point_y = 0; %Input y-coordinate of scanning start point (input 1 if you want to move by 1[grid])
%Parameter setting for fast-axis triangular wave
amplitude_fast = a_fast_grid/2; %fast axis amplitude
%Parameter setting for slow-axis triangular wave
amplitude_slow = a_slow_grid/2; %slow axis amplitude
f_slow = (f_fast)/(2*pixel_image); %Slow axis triangular wave frequency
% Generation of time vectors
total_time=256/f_fast; %Total Scan Time
t = linspace(0, total_time, fs * total_time);
x_raster = start_point_x + amplitude_fast*(2/pi)*acos(cos(2*pi*f_fast*t));
y_raster = start_point_y + amplitude_slow*(2/pi)*acos(cos(2*pi*f_slow*t));
x_dither = dr*cos(2*pi*fm*t);
y_dither = dr*sin(2*pi*fm*t);
x = x_raster + x_dither;
y = y_raster + y_dither;
z1 = cos(2*pi*((x-y)/(sqrt(3))));
z2 = cos(2*pi*(2*y/(sqrt(3))));
z3 = cos(2*pi*((x+y)/(sqrt(3))));
z = (z1 + z2 + z3);
%Reference Signal Creation
w = 2*pi*fm ;
phi = 0 ;
reference_signal = sin(w*t+phi) ;
%Mixing signal creation
mixising_signal = z.* reference_signal ;
%Applying a low-pass filter
f_cutoff = 500 ; %Cutoff frequency [Hz] setting
lowpass_signal = lowpass(mixising_signal,f_cutoff,fs) ;
%The result of FFT.——————————————-
n = length(t); % Number of samples
f = (0:n-1)*(fs/n); % Frequency axis [Hz]
half_n = floor(n/2); % Half of data
fft_z = abs(fft(z) / n);
fft_mixising_signal = abs(fft(mixising_signal) / n);
fft_lowpass_signal = abs(fft(lowpass_signal) / n);
figure;
tiledlayout(3,1)
nexttile
plot(f(1:half_n), fft_z(1:half_n));
title(‘FFT of tunnel current’); xlabel(‘Frequency [Hz]’); ylabel(‘Amplitude’);
xlim([0 20000]),ylim([0 0.3]);
nexttile
plot(f(1:half_n), fft_mixising_signal(1:half_n));
title(‘FFT of mixing signal’); xlabel(‘Frequency [Hz]’); ylabel(‘Amplitude’);
xlim([0 20000]),ylim([0 0.3]);
nexttile
plot(f(1:half_n), fft_lowpass_signal(1:half_n));
title(‘FFT after applying low-pass’); xlabel(‘Frequency [Hz]’); ylabel(‘Amplitude’);
xlim([0 20000]),ylim([0 0.3]); I am trying to cut frequencies above the cutoff frequency using the lowpass function, but it is not working.
I am trying to cut the frequency by applying a lowpass filter to the tunnel current z multiplied by the reference signal sin(wt).
The cutoff frequency is set at 500 Hz, so when I graph the FFT, the peaks at frequencies higher than 500 Hz should disappear, but they do not.
%Parameter Setting
pixel_image = 256; %Input the number of pixels in the image obtained by raster scanning (input 2^n)
dr = 1/(2*sqrt(3)); %Enter dither circle radius [grid].
a_fast_grid = 10; %fast axis scanning range [grid]
a_slow_grid = 10; %Slow axis scanning range [grid]
fm=5000; %Dither circle modulation frequency [Hz]
fs= fm*240 ; %Sampling frequency [Hz]
f_fast = 10.2; %Input scanning frequency [Hz] (1 line scanning count in 1[s])
start_point_x = 0; %Input x-coordinate of scanning start point (input 1 if you want to move by 1[grid])
start_point_y = 0; %Input y-coordinate of scanning start point (input 1 if you want to move by 1[grid])
%Parameter setting for fast-axis triangular wave
amplitude_fast = a_fast_grid/2; %fast axis amplitude
%Parameter setting for slow-axis triangular wave
amplitude_slow = a_slow_grid/2; %slow axis amplitude
f_slow = (f_fast)/(2*pixel_image); %Slow axis triangular wave frequency
% Generation of time vectors
total_time=256/f_fast; %Total Scan Time
t = linspace(0, total_time, fs * total_time);
x_raster = start_point_x + amplitude_fast*(2/pi)*acos(cos(2*pi*f_fast*t));
y_raster = start_point_y + amplitude_slow*(2/pi)*acos(cos(2*pi*f_slow*t));
x_dither = dr*cos(2*pi*fm*t);
y_dither = dr*sin(2*pi*fm*t);
x = x_raster + x_dither;
y = y_raster + y_dither;
z1 = cos(2*pi*((x-y)/(sqrt(3))));
z2 = cos(2*pi*(2*y/(sqrt(3))));
z3 = cos(2*pi*((x+y)/(sqrt(3))));
z = (z1 + z2 + z3);
%Reference Signal Creation
w = 2*pi*fm ;
phi = 0 ;
reference_signal = sin(w*t+phi) ;
%Mixing signal creation
mixising_signal = z.* reference_signal ;
%Applying a low-pass filter
f_cutoff = 500 ; %Cutoff frequency [Hz] setting
lowpass_signal = lowpass(mixising_signal,f_cutoff,fs) ;
%The result of FFT.——————————————-
n = length(t); % Number of samples
f = (0:n-1)*(fs/n); % Frequency axis [Hz]
half_n = floor(n/2); % Half of data
fft_z = abs(fft(z) / n);
fft_mixising_signal = abs(fft(mixising_signal) / n);
fft_lowpass_signal = abs(fft(lowpass_signal) / n);
figure;
tiledlayout(3,1)
nexttile
plot(f(1:half_n), fft_z(1:half_n));
title(‘FFT of tunnel current’); xlabel(‘Frequency [Hz]’); ylabel(‘Amplitude’);
xlim([0 20000]),ylim([0 0.3]);
nexttile
plot(f(1:half_n), fft_mixising_signal(1:half_n));
title(‘FFT of mixing signal’); xlabel(‘Frequency [Hz]’); ylabel(‘Amplitude’);
xlim([0 20000]),ylim([0 0.3]);
nexttile
plot(f(1:half_n), fft_lowpass_signal(1:half_n));
title(‘FFT after applying low-pass’); xlabel(‘Frequency [Hz]’); ylabel(‘Amplitude’);
xlim([0 20000]),ylim([0 0.3]); low pass filter, matlab, signal processing MATLAB Answers — New Questions
Menubar fonts unreadably small in Linux?
This is a question which has been asked before, but to which I haven’t been able to find a satisfactory response. I’m using Matlab R2016b on Linux, with a HiDPI screen (2560×1440) on a laptop – so a lot of pixels squeezed into a small space. And the standard menu fonts are tiny – so tiny that I have to squint carefully to read them.
I understand this to be in some way related to the Java system that Matlab uses for its GUI, but I have no idea how to increase the size of the menubar/toolbar fonts and icons. It’s not included in Matlab’s preferences; from my reading I believe that these are picked up somehow from the underlying OS. Or more accurately, from the underlying Java engine.
Currently, if I want to use Matlab with readable menus, I have to change my desktop resolution to a lower one, which of course affects every other application. So I’m hoping there’s a better way?
Thanks!This is a question which has been asked before, but to which I haven’t been able to find a satisfactory response. I’m using Matlab R2016b on Linux, with a HiDPI screen (2560×1440) on a laptop – so a lot of pixels squeezed into a small space. And the standard menu fonts are tiny – so tiny that I have to squint carefully to read them.
I understand this to be in some way related to the Java system that Matlab uses for its GUI, but I have no idea how to increase the size of the menubar/toolbar fonts and icons. It’s not included in Matlab’s preferences; from my reading I believe that these are picked up somehow from the underlying OS. Or more accurately, from the underlying Java engine.
Currently, if I want to use Matlab with readable menus, I have to change my desktop resolution to a lower one, which of course affects every other application. So I’m hoping there’s a better way?
Thanks! This is a question which has been asked before, but to which I haven’t been able to find a satisfactory response. I’m using Matlab R2016b on Linux, with a HiDPI screen (2560×1440) on a laptop – so a lot of pixels squeezed into a small space. And the standard menu fonts are tiny – so tiny that I have to squint carefully to read them.
I understand this to be in some way related to the Java system that Matlab uses for its GUI, but I have no idea how to increase the size of the menubar/toolbar fonts and icons. It’s not included in Matlab’s preferences; from my reading I believe that these are picked up somehow from the underlying OS. Or more accurately, from the underlying Java engine.
Currently, if I want to use Matlab with readable menus, I have to change my desktop resolution to a lower one, which of course affects every other application. So I’m hoping there’s a better way?
Thanks! desktop, menu fonts, icons, java MATLAB Answers — New Questions
Where I make a mistake with fminimax?
Dear colleagues,
I have problem with optimisation function fminimax, which I use as a variant for regression analyses made by Curve fitter.
In the attached file are the vectors for x, y and z = f(x,y).
My code is, as follow. Sorry, I don’t know how to paste it in appropriate format:
"x=x_vremetraene;
y=y_period_pretovarvane;
z=z_111;
f = @(p) abs(p(1)*(p(2)+y).^p(3)./(x+p(4)).^p(5) – z);
F = @(p) reshape(f(p),[],1);
p0 = [1 1 1 1 1];
F(p0)
ans =
1.0e+02 *
2.314576069270182
2.796122919180851
3.081916551260510
3.284514792242277
3.441464927295814
3.926826269823946
1.650257401771352
………………………..
%by this point everything is good
format long
[p,fval] = fminimax(F,p0)
Local minimum possible. Constraints satisfied.
fminimax stopped because the size of the current search direction is less than
twice the value of the step size tolerance and constraints are
satisfied to within the value of the constraint tolerance.
<stopping criteria details>
p =
1.0e+03 *
-0.320589519017169 -2.281076321933144 -0.703130918618337 -0.366998883941303 1.591728772382496
fval =
1.0e+02 *
2.317909402603515
2.801122919180851
3.088583217927177
………"
%The expected values for fval should be about 20. But they are as large as input z data.
Local minimum possible. Constraints satisfied.
I have tried p = lsqnonlin(F,p0) for preestimation of the parameters p
but it also gives me an error message.
Error using lsqncommon (line 38)
Objective function is returning Inf or NaN values at initial point. lsqnonlin cannot continue.
Error in lsqnonlin (line 264)
lsqncommon(funfcn,xCurrent,lb,ub,options,defaultopt,caller,…
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Dear colleagues,
I have problem with optimisation function fminimax, which I use as a variant for regression analyses made by Curve fitter.
In the attached file are the vectors for x, y and z = f(x,y).
My code is, as follow. Sorry, I don’t know how to paste it in appropriate format:
"x=x_vremetraene;
y=y_period_pretovarvane;
z=z_111;
f = @(p) abs(p(1)*(p(2)+y).^p(3)./(x+p(4)).^p(5) – z);
F = @(p) reshape(f(p),[],1);
p0 = [1 1 1 1 1];
F(p0)
ans =
1.0e+02 *
2.314576069270182
2.796122919180851
3.081916551260510
3.284514792242277
3.441464927295814
3.926826269823946
1.650257401771352
………………………..
%by this point everything is good
format long
[p,fval] = fminimax(F,p0)
Local minimum possible. Constraints satisfied.
fminimax stopped because the size of the current search direction is less than
twice the value of the step size tolerance and constraints are
satisfied to within the value of the constraint tolerance.
<stopping criteria details>
p =
1.0e+03 *
-0.320589519017169 -2.281076321933144 -0.703130918618337 -0.366998883941303 1.591728772382496
fval =
1.0e+02 *
2.317909402603515
2.801122919180851
3.088583217927177
………"
%The expected values for fval should be about 20. But they are as large as input z data.
Local minimum possible. Constraints satisfied.
I have tried p = lsqnonlin(F,p0) for preestimation of the parameters p
but it also gives me an error message.
Error using lsqncommon (line 38)
Objective function is returning Inf or NaN values at initial point. lsqnonlin cannot continue.
Error in lsqnonlin (line 264)
lsqncommon(funfcn,xCurrent,lb,ub,options,defaultopt,caller,…
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Dear colleagues,
I have problem with optimisation function fminimax, which I use as a variant for regression analyses made by Curve fitter.
In the attached file are the vectors for x, y and z = f(x,y).
My code is, as follow. Sorry, I don’t know how to paste it in appropriate format:
"x=x_vremetraene;
y=y_period_pretovarvane;
z=z_111;
f = @(p) abs(p(1)*(p(2)+y).^p(3)./(x+p(4)).^p(5) – z);
F = @(p) reshape(f(p),[],1);
p0 = [1 1 1 1 1];
F(p0)
ans =
1.0e+02 *
2.314576069270182
2.796122919180851
3.081916551260510
3.284514792242277
3.441464927295814
3.926826269823946
1.650257401771352
………………………..
%by this point everything is good
format long
[p,fval] = fminimax(F,p0)
Local minimum possible. Constraints satisfied.
fminimax stopped because the size of the current search direction is less than
twice the value of the step size tolerance and constraints are
satisfied to within the value of the constraint tolerance.
<stopping criteria details>
p =
1.0e+03 *
-0.320589519017169 -2.281076321933144 -0.703130918618337 -0.366998883941303 1.591728772382496
fval =
1.0e+02 *
2.317909402603515
2.801122919180851
3.088583217927177
………"
%The expected values for fval should be about 20. But they are as large as input z data.
Local minimum possible. Constraints satisfied.
I have tried p = lsqnonlin(F,p0) for preestimation of the parameters p
but it also gives me an error message.
Error using lsqncommon (line 38)
Objective function is returning Inf or NaN values at initial point. lsqnonlin cannot continue.
Error in lsqnonlin (line 264)
lsqncommon(funfcn,xCurrent,lb,ub,options,defaultopt,caller,…
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fminimax MATLAB Answers — New Questions
how can i write the follwoing matrix [0 1 2 3;0 1 2 3;3 2 1 0;3 2 1 0] as a code defined in the groub Z_4
.. . complete matlab code MATLAB Answers — New Questions
Find the bandwidth of a signal
How can I find the bandwidth of the signal in the attached picture?How can I find the bandwidth of the signal in the attached picture? How can I find the bandwidth of the signal in the attached picture? digital signal processing MATLAB Answers — New Questions
Hi guys. How can I have display a color from RGB coordinates?
What I’d like to do is to print a color starting from its RGB coordinates. Like MS Paint tool, more or less. There already exists a tool in Matlab? ThanksWhat I’d like to do is to print a color starting from its RGB coordinates. Like MS Paint tool, more or less. There already exists a tool in Matlab? Thanks What I’d like to do is to print a color starting from its RGB coordinates. Like MS Paint tool, more or less. There already exists a tool in Matlab? Thanks color, rgb MATLAB Answers — New Questions
How to visualise the colour with a given set of RGB values?
Hi,
I have one set of RGB values
RGB=[85 270 100];
How to represent/visualise the colour in a say, 80 by 80 pixel colour patch?Hi,
I have one set of RGB values
RGB=[85 270 100];
How to represent/visualise the colour in a say, 80 by 80 pixel colour patch? Hi,
I have one set of RGB values
RGB=[85 270 100];
How to represent/visualise the colour in a say, 80 by 80 pixel colour patch? single set rgb, rgb visualisation MATLAB Answers — New Questions