Category: Matlab
Category Archives: Matlab
Simulink / Simscape Corrugated Pipe
Hi,
I am modelling a 1 dimensional two-phase fluid network with both smooth pipes and corrugated hose. The smooth pipes were straightforward as there was already a Pipe (2P) block I could use. For the corrugated hose, my understanding is that the head loss is proportional to velocity to the power of 2.31 in Neill’s correlation, and also that friction factor is significantly larger compared to smooth tubes [see https://ntrs.nasa.gov/api/citations/19660024205/downloads/19660024205.pdf], which is the reason I cannot use a Pipe (2P) block as it uses velocity squared for head loss and uses other correlations for friction factor. What would be the best way to model a corrugated hose accurately using simscape?
ThanksHi,
I am modelling a 1 dimensional two-phase fluid network with both smooth pipes and corrugated hose. The smooth pipes were straightforward as there was already a Pipe (2P) block I could use. For the corrugated hose, my understanding is that the head loss is proportional to velocity to the power of 2.31 in Neill’s correlation, and also that friction factor is significantly larger compared to smooth tubes [see https://ntrs.nasa.gov/api/citations/19660024205/downloads/19660024205.pdf], which is the reason I cannot use a Pipe (2P) block as it uses velocity squared for head loss and uses other correlations for friction factor. What would be the best way to model a corrugated hose accurately using simscape?
Thanks Hi,
I am modelling a 1 dimensional two-phase fluid network with both smooth pipes and corrugated hose. The smooth pipes were straightforward as there was already a Pipe (2P) block I could use. For the corrugated hose, my understanding is that the head loss is proportional to velocity to the power of 2.31 in Neill’s correlation, and also that friction factor is significantly larger compared to smooth tubes [see https://ntrs.nasa.gov/api/citations/19660024205/downloads/19660024205.pdf], which is the reason I cannot use a Pipe (2P) block as it uses velocity squared for head loss and uses other correlations for friction factor. What would be the best way to model a corrugated hose accurately using simscape?
Thanks corrugated, fluid flow, fluids, two-phase, pipe, simscape, simulink MATLAB Answers — New Questions
How to use validation dataset in iteration-based deep network training?
Hello
I was trying to train a Twin network using this: https://www.mathworks.com/help/deeplearning/ug/train-twin-network-for-dimensionality-reduction.html
Is there any way to validate the network using a validation dataset?
Also, if anyone got good accuracy with this network or can suggest another similar matlab example, that would be much appreciated.
ThanksHello
I was trying to train a Twin network using this: https://www.mathworks.com/help/deeplearning/ug/train-twin-network-for-dimensionality-reduction.html
Is there any way to validate the network using a validation dataset?
Also, if anyone got good accuracy with this network or can suggest another similar matlab example, that would be much appreciated.
Thanks Hello
I was trying to train a Twin network using this: https://www.mathworks.com/help/deeplearning/ug/train-twin-network-for-dimensionality-reduction.html
Is there any way to validate the network using a validation dataset?
Also, if anyone got good accuracy with this network or can suggest another similar matlab example, that would be much appreciated.
Thanks twin network, validation data, accuracy MATLAB Answers — New Questions
How to troubleshoot pixhawk build error problem during executing example file?
Hello,
I want to execute the example of Send and Receive Serial Data Using PX4 Autopilots Support Package.
I followed the steps outlined in the link above, and the diagnostic results showed the following:
An error occurred stating that the index exceeds the array bounds. I tried looking for a solution to this issue but couldn’t find any relevant sources. If anyone knows how to resolve this problem, please let me know.Hello,
I want to execute the example of Send and Receive Serial Data Using PX4 Autopilots Support Package.
I followed the steps outlined in the link above, and the diagnostic results showed the following:
An error occurred stating that the index exceeds the array bounds. I tried looking for a solution to this issue but couldn’t find any relevant sources. If anyone knows how to resolve this problem, please let me know. Hello,
I want to execute the example of Send and Receive Serial Data Using PX4 Autopilots Support Package.
I followed the steps outlined in the link above, and the diagnostic results showed the following:
An error occurred stating that the index exceeds the array bounds. I tried looking for a solution to this issue but couldn’t find any relevant sources. If anyone knows how to resolve this problem, please let me know. px4, build failed MATLAB Answers — New Questions
Params chnage of simulink simulation params in runtime
Hello all,
As of now I use:
Can be simulinks blocks udes all listed including during simulation? So I see what blockks are used and ster the params during simulation?
Is there any browser of parametrs of the simulation where simulink simulation params are monitored? Params to be readable and writeable but no need to visualize them (graph, plots) just monitoring and change during simulation especially a large scale simulation ?Hello all,
As of now I use:
Can be simulinks blocks udes all listed including during simulation? So I see what blockks are used and ster the params during simulation?
Is there any browser of parametrs of the simulation where simulink simulation params are monitored? Params to be readable and writeable but no need to visualize them (graph, plots) just monitoring and change during simulation especially a large scale simulation ? Hello all,
As of now I use:
Can be simulinks blocks udes all listed including during simulation? So I see what blockks are used and ster the params during simulation?
Is there any browser of parametrs of the simulation where simulink simulation params are monitored? Params to be readable and writeable but no need to visualize them (graph, plots) just monitoring and change during simulation especially a large scale simulation ? parametrs chane for simulink simulation MATLAB Answers — New Questions
understanding a newly proposed STA/LTA algorithm
given below is the modified STA/LTA equation.
from my understanding i have formulated the code as follows.Kindly go through the code and correct me if my notion is wrong
clc
clear all
%% Data Inputs
Acc_EW = importdata("ADIB.HHE.dat")
Acc_NS = importdata("ADIB.HHN.dat");
Acc_ver = importdata("ADIB.HHZ.dat");
Fs = 100; %sampling frequency
%% Signal Pre-Processing
%Filter Design
digfilt = designfilt(‘lowpassiir’, ‘PassbandFrequency’, 20, ‘StopbandFrequency’, 25, ‘PassbandRipple’, 1, ‘StopbandAttenuation’, 60, ‘SampleRate’, 200);
% Filtering Data
Acc_EW_filt = filter(digfilt,Acc_EW);
Acc_NS_filt = filter(digfilt,Acc_NS);
Acc_ver_filt = filter(digfilt,Acc_ver);
Fhp = 0.8; % high pass filter cutofff frequency
[b1,a1] = butter(3,Fhp/Fs,’high’); %3rd order high pass butterworth filter
fildat = filter(b1,a1,Acc_ver); % filtered acceleration data
vel = cumtrapz(fildat)./Fs; % Integrating acceleration data for velocity
[b2,a2] = butter(3,Fhp/Fs,’high’); %3rd order high pass butterworth filter
fildat1 = filter(b2,a2,vel); % filtered velocity data
dis = cumtrapz(fildat1)./Fs; % Integrating velocity data for displacement
peakToPeakRange = max(fildat) – min(fildat);
dt = 1/Fs; %sampling time
nt = length(fildat); % length of the input signal
time = (1:nt).*dt; % time duration of the input signal
%% STA-LTA Algorithm gor P-Wave detection
stw = 0.2; %short time window length
ltw = 70; %long time window length
thresh = 3; % Threshold
thresh1 = 4;
%t = 1;
nl = fix(ltw / dt); %no. of data points in the long time window
ns = fix(stw / dt); %no. of data points in the short time window
nt = length(fildat);
sra = zeros(1, nt);
%%this where i have modified accroding to excerpt from the paper-‘Framework
%%for Automated Earthquake Event Detection Based On Denoising by Adaptive
%%Filter’
for k = nl+1:nt
staz(k,1) = (1/ns)* trapz(abs(fildat(k-ns:k)));
ltaz(k,1) = (1/nl)* trapz(abs(fildat(k-nl:k)));
sta(k,1) = (1/ns)* [(staz(k-1)*ns)-fildat(k-ns)-fildat(k)];
lta(k,1) = (1/nl)* [(ltaz(k-1)*nl)-fildat(k-nl)-fildat(k)];
end
for l = nl+1: nt
sra(l) = sta(l)/lta(l);
end
itm = find(sra > thresh);
if ~isempty(itm)
itmax=itm(1);
end
tp =itmax*dt; % P-wave arriving time
fprintf(‘P-Wave detection time for threshold 4 = %f secondn’, tp);
itm1 = find(sra > thresh1);
if ~isempty(itm1)
itmax1 = itm1(1);
end
tp1 = itmax1*dt; % P-wave arriving time
fprintf(‘P-Wave detection time for threshold 3 = %f secondn’, tp1);
%% S-wave arrival time
pkHts = 0.72; % 10 percent
[pk2,t22] = findpeaks(Acc_NS_dlycompensated,Fs,’MinPeakHeight’,pkHts*max(Acc_ver_dlycompensated),’Npeaks’,1);
[pk3,t33] = findpeaks(Acc_EW_dlycompensated,Fs,’MinPeakHeight’,pkHts*max(Acc_ver_dlycompensated),’Npeaks’,1);
display(sprintf(‘S-wave found on EW component at %f seconds and on NS componet at %f seconds,’, t33,t22));
if(t22<t33)
display(‘S-wave detected first on North-South component’);
else
display(‘S-wave detected first on East-West component’);
end
ts = min(t22,t33);
line([ts,ts],[min(get(gca,’Ylim’))],’linestyle’,’–‘,’linewidth’,2,’color’,’red’);
%% Tauc , Pd and Magnitude calculations
vel_sq = vel.^2;
dis_sq = dis.^2;
r1 = trapz(vel_sq((itmax):(itmax+300)));
r2 = trapz(dis_sq((itmax):(itmax+300)));
r = r1/r2;
tauc = 2*pi/sqrt(r);
pd = max(dis((itmax):(itmax+300)));
mag_tauc = (log(tauc) + 3.45)/0.47 %Coefficients varies from region to region
mag_pd = (0.873*((log(pd)+6.3)/0.513))+4.74 %Coefficients varies from region to regiongiven below is the modified STA/LTA equation.
from my understanding i have formulated the code as follows.Kindly go through the code and correct me if my notion is wrong
clc
clear all
%% Data Inputs
Acc_EW = importdata("ADIB.HHE.dat")
Acc_NS = importdata("ADIB.HHN.dat");
Acc_ver = importdata("ADIB.HHZ.dat");
Fs = 100; %sampling frequency
%% Signal Pre-Processing
%Filter Design
digfilt = designfilt(‘lowpassiir’, ‘PassbandFrequency’, 20, ‘StopbandFrequency’, 25, ‘PassbandRipple’, 1, ‘StopbandAttenuation’, 60, ‘SampleRate’, 200);
% Filtering Data
Acc_EW_filt = filter(digfilt,Acc_EW);
Acc_NS_filt = filter(digfilt,Acc_NS);
Acc_ver_filt = filter(digfilt,Acc_ver);
Fhp = 0.8; % high pass filter cutofff frequency
[b1,a1] = butter(3,Fhp/Fs,’high’); %3rd order high pass butterworth filter
fildat = filter(b1,a1,Acc_ver); % filtered acceleration data
vel = cumtrapz(fildat)./Fs; % Integrating acceleration data for velocity
[b2,a2] = butter(3,Fhp/Fs,’high’); %3rd order high pass butterworth filter
fildat1 = filter(b2,a2,vel); % filtered velocity data
dis = cumtrapz(fildat1)./Fs; % Integrating velocity data for displacement
peakToPeakRange = max(fildat) – min(fildat);
dt = 1/Fs; %sampling time
nt = length(fildat); % length of the input signal
time = (1:nt).*dt; % time duration of the input signal
%% STA-LTA Algorithm gor P-Wave detection
stw = 0.2; %short time window length
ltw = 70; %long time window length
thresh = 3; % Threshold
thresh1 = 4;
%t = 1;
nl = fix(ltw / dt); %no. of data points in the long time window
ns = fix(stw / dt); %no. of data points in the short time window
nt = length(fildat);
sra = zeros(1, nt);
%%this where i have modified accroding to excerpt from the paper-‘Framework
%%for Automated Earthquake Event Detection Based On Denoising by Adaptive
%%Filter’
for k = nl+1:nt
staz(k,1) = (1/ns)* trapz(abs(fildat(k-ns:k)));
ltaz(k,1) = (1/nl)* trapz(abs(fildat(k-nl:k)));
sta(k,1) = (1/ns)* [(staz(k-1)*ns)-fildat(k-ns)-fildat(k)];
lta(k,1) = (1/nl)* [(ltaz(k-1)*nl)-fildat(k-nl)-fildat(k)];
end
for l = nl+1: nt
sra(l) = sta(l)/lta(l);
end
itm = find(sra > thresh);
if ~isempty(itm)
itmax=itm(1);
end
tp =itmax*dt; % P-wave arriving time
fprintf(‘P-Wave detection time for threshold 4 = %f secondn’, tp);
itm1 = find(sra > thresh1);
if ~isempty(itm1)
itmax1 = itm1(1);
end
tp1 = itmax1*dt; % P-wave arriving time
fprintf(‘P-Wave detection time for threshold 3 = %f secondn’, tp1);
%% S-wave arrival time
pkHts = 0.72; % 10 percent
[pk2,t22] = findpeaks(Acc_NS_dlycompensated,Fs,’MinPeakHeight’,pkHts*max(Acc_ver_dlycompensated),’Npeaks’,1);
[pk3,t33] = findpeaks(Acc_EW_dlycompensated,Fs,’MinPeakHeight’,pkHts*max(Acc_ver_dlycompensated),’Npeaks’,1);
display(sprintf(‘S-wave found on EW component at %f seconds and on NS componet at %f seconds,’, t33,t22));
if(t22<t33)
display(‘S-wave detected first on North-South component’);
else
display(‘S-wave detected first on East-West component’);
end
ts = min(t22,t33);
line([ts,ts],[min(get(gca,’Ylim’))],’linestyle’,’–‘,’linewidth’,2,’color’,’red’);
%% Tauc , Pd and Magnitude calculations
vel_sq = vel.^2;
dis_sq = dis.^2;
r1 = trapz(vel_sq((itmax):(itmax+300)));
r2 = trapz(dis_sq((itmax):(itmax+300)));
r = r1/r2;
tauc = 2*pi/sqrt(r);
pd = max(dis((itmax):(itmax+300)));
mag_tauc = (log(tauc) + 3.45)/0.47 %Coefficients varies from region to region
mag_pd = (0.873*((log(pd)+6.3)/0.513))+4.74 %Coefficients varies from region to region given below is the modified STA/LTA equation.
from my understanding i have formulated the code as follows.Kindly go through the code and correct me if my notion is wrong
clc
clear all
%% Data Inputs
Acc_EW = importdata("ADIB.HHE.dat")
Acc_NS = importdata("ADIB.HHN.dat");
Acc_ver = importdata("ADIB.HHZ.dat");
Fs = 100; %sampling frequency
%% Signal Pre-Processing
%Filter Design
digfilt = designfilt(‘lowpassiir’, ‘PassbandFrequency’, 20, ‘StopbandFrequency’, 25, ‘PassbandRipple’, 1, ‘StopbandAttenuation’, 60, ‘SampleRate’, 200);
% Filtering Data
Acc_EW_filt = filter(digfilt,Acc_EW);
Acc_NS_filt = filter(digfilt,Acc_NS);
Acc_ver_filt = filter(digfilt,Acc_ver);
Fhp = 0.8; % high pass filter cutofff frequency
[b1,a1] = butter(3,Fhp/Fs,’high’); %3rd order high pass butterworth filter
fildat = filter(b1,a1,Acc_ver); % filtered acceleration data
vel = cumtrapz(fildat)./Fs; % Integrating acceleration data for velocity
[b2,a2] = butter(3,Fhp/Fs,’high’); %3rd order high pass butterworth filter
fildat1 = filter(b2,a2,vel); % filtered velocity data
dis = cumtrapz(fildat1)./Fs; % Integrating velocity data for displacement
peakToPeakRange = max(fildat) – min(fildat);
dt = 1/Fs; %sampling time
nt = length(fildat); % length of the input signal
time = (1:nt).*dt; % time duration of the input signal
%% STA-LTA Algorithm gor P-Wave detection
stw = 0.2; %short time window length
ltw = 70; %long time window length
thresh = 3; % Threshold
thresh1 = 4;
%t = 1;
nl = fix(ltw / dt); %no. of data points in the long time window
ns = fix(stw / dt); %no. of data points in the short time window
nt = length(fildat);
sra = zeros(1, nt);
%%this where i have modified accroding to excerpt from the paper-‘Framework
%%for Automated Earthquake Event Detection Based On Denoising by Adaptive
%%Filter’
for k = nl+1:nt
staz(k,1) = (1/ns)* trapz(abs(fildat(k-ns:k)));
ltaz(k,1) = (1/nl)* trapz(abs(fildat(k-nl:k)));
sta(k,1) = (1/ns)* [(staz(k-1)*ns)-fildat(k-ns)-fildat(k)];
lta(k,1) = (1/nl)* [(ltaz(k-1)*nl)-fildat(k-nl)-fildat(k)];
end
for l = nl+1: nt
sra(l) = sta(l)/lta(l);
end
itm = find(sra > thresh);
if ~isempty(itm)
itmax=itm(1);
end
tp =itmax*dt; % P-wave arriving time
fprintf(‘P-Wave detection time for threshold 4 = %f secondn’, tp);
itm1 = find(sra > thresh1);
if ~isempty(itm1)
itmax1 = itm1(1);
end
tp1 = itmax1*dt; % P-wave arriving time
fprintf(‘P-Wave detection time for threshold 3 = %f secondn’, tp1);
%% S-wave arrival time
pkHts = 0.72; % 10 percent
[pk2,t22] = findpeaks(Acc_NS_dlycompensated,Fs,’MinPeakHeight’,pkHts*max(Acc_ver_dlycompensated),’Npeaks’,1);
[pk3,t33] = findpeaks(Acc_EW_dlycompensated,Fs,’MinPeakHeight’,pkHts*max(Acc_ver_dlycompensated),’Npeaks’,1);
display(sprintf(‘S-wave found on EW component at %f seconds and on NS componet at %f seconds,’, t33,t22));
if(t22<t33)
display(‘S-wave detected first on North-South component’);
else
display(‘S-wave detected first on East-West component’);
end
ts = min(t22,t33);
line([ts,ts],[min(get(gca,’Ylim’))],’linestyle’,’–‘,’linewidth’,2,’color’,’red’);
%% Tauc , Pd and Magnitude calculations
vel_sq = vel.^2;
dis_sq = dis.^2;
r1 = trapz(vel_sq((itmax):(itmax+300)));
r2 = trapz(dis_sq((itmax):(itmax+300)));
r = r1/r2;
tauc = 2*pi/sqrt(r);
pd = max(dis((itmax):(itmax+300)));
mag_tauc = (log(tauc) + 3.45)/0.47 %Coefficients varies from region to region
mag_pd = (0.873*((log(pd)+6.3)/0.513))+4.74 %Coefficients varies from region to region sta/lta, least mean square, algorithm, detection MATLAB Answers — New Questions
Initial condition from external source for discrete integration diuring runtime
I have a discrite integration with simulink and externaly added the condition:
when changing the value of external source (in my case mec_init_pos) – does it have influence on simulation integration or just for strating simulation and very first initialization of the integration?I have a discrite integration with simulink and externaly added the condition:
when changing the value of external source (in my case mec_init_pos) – does it have influence on simulation integration or just for strating simulation and very first initialization of the integration? I have a discrite integration with simulink and externaly added the condition:
when changing the value of external source (in my case mec_init_pos) – does it have influence on simulation integration or just for strating simulation and very first initialization of the integration? numerical integration initialization from external MATLAB Answers — New Questions
A simple question regarding image processing
My knowledge regarding image processing is limited, so I ask here instead of risking making stupid mistakes.
I have a set of images of a fluorescent substance, taken in a dark room under illumination. The idea is to use this captured intensity to make tomographic reconstructions for the downward z-direction for each pixel in the image. The problem is that the images are grainy due to being taken in the dark, thus some pixels in the ROI (the white circle in the image below) are dark, and reconstruction with these pixels would yield unrealistic results.
So the question is: what is the most reasonable way to address the issue of the dark pixels?My knowledge regarding image processing is limited, so I ask here instead of risking making stupid mistakes.
I have a set of images of a fluorescent substance, taken in a dark room under illumination. The idea is to use this captured intensity to make tomographic reconstructions for the downward z-direction for each pixel in the image. The problem is that the images are grainy due to being taken in the dark, thus some pixels in the ROI (the white circle in the image below) are dark, and reconstruction with these pixels would yield unrealistic results.
So the question is: what is the most reasonable way to address the issue of the dark pixels? My knowledge regarding image processing is limited, so I ask here instead of risking making stupid mistakes.
I have a set of images of a fluorescent substance, taken in a dark room under illumination. The idea is to use this captured intensity to make tomographic reconstructions for the downward z-direction for each pixel in the image. The problem is that the images are grainy due to being taken in the dark, thus some pixels in the ROI (the white circle in the image below) are dark, and reconstruction with these pixels would yield unrealistic results.
So the question is: what is the most reasonable way to address the issue of the dark pixels? image processing, image analysis MATLAB Answers — New Questions
Use of symbolix toolbox to derive PI controller Kp,Ki
I’d like try to use Symbolic toolbox to derive closed loop transfer function of control system:
to help design PI controller as of standard 2nd order system compring charasterictic polynomial with that of a standard second order
to get out:
Please advice how to achive it with Symbolic toolbox?I’d like try to use Symbolic toolbox to derive closed loop transfer function of control system:
to help design PI controller as of standard 2nd order system compring charasterictic polynomial with that of a standard second order
to get out:
Please advice how to achive it with Symbolic toolbox? I’d like try to use Symbolic toolbox to derive closed loop transfer function of control system:
to help design PI controller as of standard 2nd order system compring charasterictic polynomial with that of a standard second order
to get out:
Please advice how to achive it with Symbolic toolbox? symbolic toolbox use MATLAB Answers — New Questions
Function Call Trigger Problem
Outport block must be connected to one of the following blocks: an exported function, a Simulink function, an Initialize/Reset/Terminate function, a Merge or Mux block that is driven by exported functions, or a Ground block.
How can i solve this problem? Thank you.Outport block must be connected to one of the following blocks: an exported function, a Simulink function, an Initialize/Reset/Terminate function, a Merge or Mux block that is driven by exported functions, or a Ground block.
How can i solve this problem? Thank you. Outport block must be connected to one of the following blocks: an exported function, a Simulink function, an Initialize/Reset/Terminate function, a Merge or Mux block that is driven by exported functions, or a Ground block.
How can i solve this problem? Thank you. matlab2024a MATLAB Answers — New Questions
How do I create a game update in a while loop
I have this project for class to make a game and for this game I wanted to add an update feature where every 1/30 seconds it completes a "tick." Basically running a while loop where it starts a timer at the begining, runs some functions, and then waits for the timer to hit 1/30 seconds before looping again to keep the game smooth. I’ve looked into the timer function but haven’t been able to get it to work and I was hoping for some help.I have this project for class to make a game and for this game I wanted to add an update feature where every 1/30 seconds it completes a "tick." Basically running a while loop where it starts a timer at the begining, runs some functions, and then waits for the timer to hit 1/30 seconds before looping again to keep the game smooth. I’ve looked into the timer function but haven’t been able to get it to work and I was hoping for some help. I have this project for class to make a game and for this game I wanted to add an update feature where every 1/30 seconds it completes a "tick." Basically running a while loop where it starts a timer at the begining, runs some functions, and then waits for the timer to hit 1/30 seconds before looping again to keep the game smooth. I’ve looked into the timer function but haven’t been able to get it to work and I was hoping for some help. while loop, loops MATLAB Answers — New Questions
How to choose the optimum values of the training options Transfer learning of the pretrain Deep networks in MATLAB
Dear all I have a question, I am using Transfer Learning of the pretraining Deep learning networks I would like to know how to choose the optimum values of the training options(Solver, initial learning rate, max epoch, miniBatchsize etc) should I keep trying different values or choosing the default values, pleaseDear all I have a question, I am using Transfer Learning of the pretraining Deep learning networks I would like to know how to choose the optimum values of the training options(Solver, initial learning rate, max epoch, miniBatchsize etc) should I keep trying different values or choosing the default values, please Dear all I have a question, I am using Transfer Learning of the pretraining Deep learning networks I would like to know how to choose the optimum values of the training options(Solver, initial learning rate, max epoch, miniBatchsize etc) should I keep trying different values or choosing the default values, please training opitions MATLAB Answers — New Questions
Assigning PWM Ports in Speedgoat Motion Control HDL I/O Blockset for IO334 with 3xx-21 Extension Card?
I want to use pwm_example_hdlc.slx example from Speedgoat Motion Control HDL I/O Blockset v1.0 (R2024b). The Example is originally set to use with IO324. I am using Speedgoat P3 with IO334 and 3xx-21 Extension card.
In HDL Workflow Advisor, step 1.3 Set Target Interface, I need to assign interfaces for ports. It seems that I do not have any suitable option available for TTL_PMW_x and TTL_CAP_x ports (it defaults to "No Interface Specified"). In this webinar (19:37) it can be seen that interface option IO3XX-21 [0:55] should be available.
How can solve this problem?I want to use pwm_example_hdlc.slx example from Speedgoat Motion Control HDL I/O Blockset v1.0 (R2024b). The Example is originally set to use with IO324. I am using Speedgoat P3 with IO334 and 3xx-21 Extension card.
In HDL Workflow Advisor, step 1.3 Set Target Interface, I need to assign interfaces for ports. It seems that I do not have any suitable option available for TTL_PMW_x and TTL_CAP_x ports (it defaults to "No Interface Specified"). In this webinar (19:37) it can be seen that interface option IO3XX-21 [0:55] should be available.
How can solve this problem? I want to use pwm_example_hdlc.slx example from Speedgoat Motion Control HDL I/O Blockset v1.0 (R2024b). The Example is originally set to use with IO324. I am using Speedgoat P3 with IO334 and 3xx-21 Extension card.
In HDL Workflow Advisor, step 1.3 Set Target Interface, I need to assign interfaces for ports. It seems that I do not have any suitable option available for TTL_PMW_x and TTL_CAP_x ports (it defaults to "No Interface Specified"). In this webinar (19:37) it can be seen that interface option IO3XX-21 [0:55] should be available.
How can solve this problem? speedgoat, hdl, pwm, real-time MATLAB Answers — New Questions
How to implemented boundary condition in solving convection diffusion equation in cylindical coordinate
For C_c at r = R_c, you can consider that node as C(length(r1),j)
For C_a at r = R_c, you can consider that node as C(length(r1)+1,j)
Then, via central difference,
dC_c/dr (at r = R_c) can be written as (C(length(r1)+1,j)-C(length(r1)-1,j))/(del_r)
Similarly, dC_a/dr (at r = R_c) can be written as (C(length(r1)+2,j)-C(length(r1),j))/(del_r)
Try to suitably implement the above in the condition mass flux continuity condition at r = R_c, and check what happens. Also, ensure that the other conditions are correctly implemented, and then run the code.
I want to know how to write this in matlab so that I will not get error. I have aslo attached my matlab file hereFor C_c at r = R_c, you can consider that node as C(length(r1),j)
For C_a at r = R_c, you can consider that node as C(length(r1)+1,j)
Then, via central difference,
dC_c/dr (at r = R_c) can be written as (C(length(r1)+1,j)-C(length(r1)-1,j))/(del_r)
Similarly, dC_a/dr (at r = R_c) can be written as (C(length(r1)+2,j)-C(length(r1),j))/(del_r)
Try to suitably implement the above in the condition mass flux continuity condition at r = R_c, and check what happens. Also, ensure that the other conditions are correctly implemented, and then run the code.
I want to know how to write this in matlab so that I will not get error. I have aslo attached my matlab file here For C_c at r = R_c, you can consider that node as C(length(r1),j)
For C_a at r = R_c, you can consider that node as C(length(r1)+1,j)
Then, via central difference,
dC_c/dr (at r = R_c) can be written as (C(length(r1)+1,j)-C(length(r1)-1,j))/(del_r)
Similarly, dC_a/dr (at r = R_c) can be written as (C(length(r1)+2,j)-C(length(r1),j))/(del_r)
Try to suitably implement the above in the condition mass flux continuity condition at r = R_c, and check what happens. Also, ensure that the other conditions are correctly implemented, and then run the code.
I want to know how to write this in matlab so that I will not get error. I have aslo attached my matlab file here boundary condition, pde MATLAB Answers — New Questions
Simulink matrix multiply, dimension error
Below is a small part of my Simulink model. The function is only a repmat that repeats the vector into 9 rows. When the matrix multiply is doing a "matrix" multiplication, all is good and I get a 9×9 matrix out.
I then need to change the Matrix Multiply to do "element-wise" multiplicaton. So, I remove uT and change the property to element-wise.
But as you can see, it fails to run and I get the below error message which does not make sence because it fails on the exact dimensions that are expected of it:
The only caveat to this whole scenario is that both the data that goes into Transpose2 and into "Matrix Multiply" is actually a 3D data in the form of 394x1x22 and 9x394x22, respectively. So, initially I thought it could be that Simulink mixes up this 3rd dimension somehow. However, this 3rd dimension exists in the rest of my model and Simulink is happy with it AND when I change the element-wise to matrix-multiplication again, Simulink is happy. So, I cannot see how that 3rd dimension will only go wrong in this specific scenario that I am interested in, i.e. element-wise multiplication.
Any ideas are greatly welcome.Below is a small part of my Simulink model. The function is only a repmat that repeats the vector into 9 rows. When the matrix multiply is doing a "matrix" multiplication, all is good and I get a 9×9 matrix out.
I then need to change the Matrix Multiply to do "element-wise" multiplicaton. So, I remove uT and change the property to element-wise.
But as you can see, it fails to run and I get the below error message which does not make sence because it fails on the exact dimensions that are expected of it:
The only caveat to this whole scenario is that both the data that goes into Transpose2 and into "Matrix Multiply" is actually a 3D data in the form of 394x1x22 and 9x394x22, respectively. So, initially I thought it could be that Simulink mixes up this 3rd dimension somehow. However, this 3rd dimension exists in the rest of my model and Simulink is happy with it AND when I change the element-wise to matrix-multiplication again, Simulink is happy. So, I cannot see how that 3rd dimension will only go wrong in this specific scenario that I am interested in, i.e. element-wise multiplication.
Any ideas are greatly welcome. Below is a small part of my Simulink model. The function is only a repmat that repeats the vector into 9 rows. When the matrix multiply is doing a "matrix" multiplication, all is good and I get a 9×9 matrix out.
I then need to change the Matrix Multiply to do "element-wise" multiplicaton. So, I remove uT and change the property to element-wise.
But as you can see, it fails to run and I get the below error message which does not make sence because it fails on the exact dimensions that are expected of it:
The only caveat to this whole scenario is that both the data that goes into Transpose2 and into "Matrix Multiply" is actually a 3D data in the form of 394x1x22 and 9x394x22, respectively. So, initially I thought it could be that Simulink mixes up this 3rd dimension somehow. However, this 3rd dimension exists in the rest of my model and Simulink is happy with it AND when I change the element-wise to matrix-multiplication again, Simulink is happy. So, I cannot see how that 3rd dimension will only go wrong in this specific scenario that I am interested in, i.e. element-wise multiplication.
Any ideas are greatly welcome. simulink, matrix MATLAB Answers — New Questions
Hi, how to obtain the parameter number of the trained deep network in MATLAB ?
Hi, how to obtain the parameter number of the trained deep network in MATLAB?Hi, how to obtain the parameter number of the trained deep network in MATLAB? Hi, how to obtain the parameter number of the trained deep network in MATLAB? deep learning MATLAB Answers — New Questions
Finding distance between centers of circles by manually selecting muliple pairs
I am having trouble finding the correct distances from circle to circle. Is there a way to select manually which circles to measure the distances between? I would need to select multiple pairs and a circle can be in a pair more than once. Then be able to advance the program when finished. Not all circles are necessary to be selected. The circle finding itself works nicely.
I included the entire code. It grabs images from a file to analyze. Thank you.
directory = uigetdir;
files = dir(fullfile(directory, ‘*.bmp’));
for k = 1:length(files)
fileName = files(k).name;
fullFilePath = fullfile(directory, fileName);
fprintf(1, ‘Processing: %sn’, fullFilePath);
rgb = imread(fullFilePath);
rgb = imcrop(rgb,[950 0 400 750]);
rgb = rgb2hsv(rgb);
rgb = rgb(:,:,3);
rgb = imadjust(rgb, [0.1 0.85]);
%rgb = im2gray(rgb);
rgb = adapthisteq(rgb);
%crop
rgb = im2bw(rgb,0.3);
%binary conversion
imshow(rgb)
d = drawline;
pos = d.Position;
diffPos = diff(pos);
diameter = hypot(diffPos(1),diffPos(2))
[centers,radii] = imfindcircles(rgb,[10 400],’ObjectPolarity’,’dark’,’Sensitivity’,0.8)
imshow(rgb)
h = viscircles(centers,radii);
[centers,radii] = imfindcircles(rgb,[10 400],’ObjectPolarity’,’dark’, …
‘Sensitivity’,0.8);
length(centers)
%
delete(h) % Delete previously drawn circles
h = viscircles(centers,radii);
[centers,radii] = imfindcircles(rgb,[10 400],’ObjectPolarity’,’dark’, …
‘Sensitivity’,0.8,’Method’,’twostage’);
delete(h)
h = viscircles(centers,radii);
%hBright = viscircles(centersBright, radiiBright,’Color’,’b’);
h = viscircles(centers,radii);
pix = 0.00001030927835;
%calibration for pix to meter
Yp(:) = centers(:,2);
%need to do every other circle, This does distance between every one
distance = abs(diff(Yp))
%distance between center in pix
Ydiff = distance*pix
%distance between center in meters
v = 0.142082
% change this variable ‘v’ for every test run
frequency = Ydiff/v
% units 1/s
diameter = 0.00635;
% units m
Strouhal = (frequency * diameter) / v
%final strouhal number
endI am having trouble finding the correct distances from circle to circle. Is there a way to select manually which circles to measure the distances between? I would need to select multiple pairs and a circle can be in a pair more than once. Then be able to advance the program when finished. Not all circles are necessary to be selected. The circle finding itself works nicely.
I included the entire code. It grabs images from a file to analyze. Thank you.
directory = uigetdir;
files = dir(fullfile(directory, ‘*.bmp’));
for k = 1:length(files)
fileName = files(k).name;
fullFilePath = fullfile(directory, fileName);
fprintf(1, ‘Processing: %sn’, fullFilePath);
rgb = imread(fullFilePath);
rgb = imcrop(rgb,[950 0 400 750]);
rgb = rgb2hsv(rgb);
rgb = rgb(:,:,3);
rgb = imadjust(rgb, [0.1 0.85]);
%rgb = im2gray(rgb);
rgb = adapthisteq(rgb);
%crop
rgb = im2bw(rgb,0.3);
%binary conversion
imshow(rgb)
d = drawline;
pos = d.Position;
diffPos = diff(pos);
diameter = hypot(diffPos(1),diffPos(2))
[centers,radii] = imfindcircles(rgb,[10 400],’ObjectPolarity’,’dark’,’Sensitivity’,0.8)
imshow(rgb)
h = viscircles(centers,radii);
[centers,radii] = imfindcircles(rgb,[10 400],’ObjectPolarity’,’dark’, …
‘Sensitivity’,0.8);
length(centers)
%
delete(h) % Delete previously drawn circles
h = viscircles(centers,radii);
[centers,radii] = imfindcircles(rgb,[10 400],’ObjectPolarity’,’dark’, …
‘Sensitivity’,0.8,’Method’,’twostage’);
delete(h)
h = viscircles(centers,radii);
%hBright = viscircles(centersBright, radiiBright,’Color’,’b’);
h = viscircles(centers,radii);
pix = 0.00001030927835;
%calibration for pix to meter
Yp(:) = centers(:,2);
%need to do every other circle, This does distance between every one
distance = abs(diff(Yp))
%distance between center in pix
Ydiff = distance*pix
%distance between center in meters
v = 0.142082
% change this variable ‘v’ for every test run
frequency = Ydiff/v
% units 1/s
diameter = 0.00635;
% units m
Strouhal = (frequency * diameter) / v
%final strouhal number
end I am having trouble finding the correct distances from circle to circle. Is there a way to select manually which circles to measure the distances between? I would need to select multiple pairs and a circle can be in a pair more than once. Then be able to advance the program when finished. Not all circles are necessary to be selected. The circle finding itself works nicely.
I included the entire code. It grabs images from a file to analyze. Thank you.
directory = uigetdir;
files = dir(fullfile(directory, ‘*.bmp’));
for k = 1:length(files)
fileName = files(k).name;
fullFilePath = fullfile(directory, fileName);
fprintf(1, ‘Processing: %sn’, fullFilePath);
rgb = imread(fullFilePath);
rgb = imcrop(rgb,[950 0 400 750]);
rgb = rgb2hsv(rgb);
rgb = rgb(:,:,3);
rgb = imadjust(rgb, [0.1 0.85]);
%rgb = im2gray(rgb);
rgb = adapthisteq(rgb);
%crop
rgb = im2bw(rgb,0.3);
%binary conversion
imshow(rgb)
d = drawline;
pos = d.Position;
diffPos = diff(pos);
diameter = hypot(diffPos(1),diffPos(2))
[centers,radii] = imfindcircles(rgb,[10 400],’ObjectPolarity’,’dark’,’Sensitivity’,0.8)
imshow(rgb)
h = viscircles(centers,radii);
[centers,radii] = imfindcircles(rgb,[10 400],’ObjectPolarity’,’dark’, …
‘Sensitivity’,0.8);
length(centers)
%
delete(h) % Delete previously drawn circles
h = viscircles(centers,radii);
[centers,radii] = imfindcircles(rgb,[10 400],’ObjectPolarity’,’dark’, …
‘Sensitivity’,0.8,’Method’,’twostage’);
delete(h)
h = viscircles(centers,radii);
%hBright = viscircles(centersBright, radiiBright,’Color’,’b’);
h = viscircles(centers,radii);
pix = 0.00001030927835;
%calibration for pix to meter
Yp(:) = centers(:,2);
%need to do every other circle, This does distance between every one
distance = abs(diff(Yp))
%distance between center in pix
Ydiff = distance*pix
%distance between center in meters
v = 0.142082
% change this variable ‘v’ for every test run
frequency = Ydiff/v
% units 1/s
diameter = 0.00635;
% units m
Strouhal = (frequency * diameter) / v
%final strouhal number
end image analysis MATLAB Answers — New Questions
matlab python engine module not recognized
I am having trouble using the matlab python engine. I tried this piece of code from the mathworks website:
import matlab.engine
if __name__ == ‘__main__’:
eng = matlab.engine.start_matlab()
x = 4.0
eng.workspace[‘y’] = x
a = eng.eval(‘sqrt(y)’)
print(a)
pass
But pycharm is giving me an error saying "ModuleNotFoundError: No module named ‘matlab.engine’; ‘matlab’ is not a package". I am using python 3.6 and matlab 2018. I saw that these are the supported versions on website, I saw a similar post about this problem but I can’t even run my program from python command line. I also can’t find teh matlab.py in my python site-packages, although I have the matlab folder in packages.I am having trouble using the matlab python engine. I tried this piece of code from the mathworks website:
import matlab.engine
if __name__ == ‘__main__’:
eng = matlab.engine.start_matlab()
x = 4.0
eng.workspace[‘y’] = x
a = eng.eval(‘sqrt(y)’)
print(a)
pass
But pycharm is giving me an error saying "ModuleNotFoundError: No module named ‘matlab.engine’; ‘matlab’ is not a package". I am using python 3.6 and matlab 2018. I saw that these are the supported versions on website, I saw a similar post about this problem but I can’t even run my program from python command line. I also can’t find teh matlab.py in my python site-packages, although I have the matlab folder in packages. I am having trouble using the matlab python engine. I tried this piece of code from the mathworks website:
import matlab.engine
if __name__ == ‘__main__’:
eng = matlab.engine.start_matlab()
x = 4.0
eng.workspace[‘y’] = x
a = eng.eval(‘sqrt(y)’)
print(a)
pass
But pycharm is giving me an error saying "ModuleNotFoundError: No module named ‘matlab.engine’; ‘matlab’ is not a package". I am using python 3.6 and matlab 2018. I saw that these are the supported versions on website, I saw a similar post about this problem but I can’t even run my program from python command line. I also can’t find teh matlab.py in my python site-packages, although I have the matlab folder in packages. matlab python engine, pycharm, passing python variables to matlab MATLAB Answers — New Questions
Add a colorbar for this quiver plot
I wrote a code to have a quiver plot as I attached here. I want to add a colorbar to this code as it shows the magnitude of the vectors. How can I do that?
nu1=3.87e5;
nu2=0.46e5;
v_m=2.84e5;
v_p=7.18e5;
%
% nu1=8.4;
% nu2=1;
% v_m=1;
% v_p=2.5;
s=1;
s1=-1;
kesi=1;
kesi1=-1;
DeltaSO=41.9e-3;
alpha=1;
A=0.0;
hbar=1;
V=0;
iform=complex(0.0,1.0);
for i=1:25
k_x=-0.3+2*(i-1)*0.3/25;
for j=1:25
k_y=-0.3+2*(j-1)*0.3/25;
sigmax=[0 1; 1 0];
sigmay=[0 -iform; iform 0];
sigmaz=[1 0; 0 -1];
sigma0=[1 0; 0 1];
H1=hbar*k_x*nu1*sigmay-hbar*k_y*(s*nu2*sigmax+kesi*v_m*sigma0+kesi*v_p*sigmaz)+DeltaSO*(alpha-s*kesi)*sigmax+A*(s*sigmaz-kesi*sigmax)+V*sigma0;
H2=hbar*k_x*nu1*sigmay-hbar*k_y*(s1*nu2*sigmax+kesi*v_m*sigma0+kesi*v_p*sigmaz)+DeltaSO*(alpha-s1*kesi)*sigmax+A*(s1*sigmaz-kesi*sigmax)+V*sigma0;
H3=hbar*k_x*nu1*sigmay-hbar*k_y*(s*nu2*sigmax+kesi1*v_m*sigma0+kesi1*v_p*sigmaz)+DeltaSO*(alpha-s*kesi1)*sigmax+A*(s*sigmaz-kesi1*sigmax)+V*sigma0;
H4=hbar*k_x*nu1*sigmay-hbar*k_y*(s1*nu2*sigmax+kesi1*v_m*sigma0+kesi1*v_p*sigmaz)+DeltaSO*(alpha-s1*kesi1)*sigmax+A*(s1*sigmaz-kesi1*sigmax)+V*sigma0;
[v1,E1]=eig(H1);
[v2,E2]=eig(H2);
[v3,E3]=eig(H3);
[v4,E4]=eig(H4);
KX(i,j)=k_x;
KY(i,j)=k_y;
sx(i,j)=v4(:,2)’*sigmax*v4(:,2);
sy(i,j)=v4(:,2)’*sigmay*v4(:,2);
end
end
quiver(KX,KY,sx,sy,1)
q.ShowArrowHead = ‘off’;
q.Marker = ‘o’;
QuI wrote a code to have a quiver plot as I attached here. I want to add a colorbar to this code as it shows the magnitude of the vectors. How can I do that?
nu1=3.87e5;
nu2=0.46e5;
v_m=2.84e5;
v_p=7.18e5;
%
% nu1=8.4;
% nu2=1;
% v_m=1;
% v_p=2.5;
s=1;
s1=-1;
kesi=1;
kesi1=-1;
DeltaSO=41.9e-3;
alpha=1;
A=0.0;
hbar=1;
V=0;
iform=complex(0.0,1.0);
for i=1:25
k_x=-0.3+2*(i-1)*0.3/25;
for j=1:25
k_y=-0.3+2*(j-1)*0.3/25;
sigmax=[0 1; 1 0];
sigmay=[0 -iform; iform 0];
sigmaz=[1 0; 0 -1];
sigma0=[1 0; 0 1];
H1=hbar*k_x*nu1*sigmay-hbar*k_y*(s*nu2*sigmax+kesi*v_m*sigma0+kesi*v_p*sigmaz)+DeltaSO*(alpha-s*kesi)*sigmax+A*(s*sigmaz-kesi*sigmax)+V*sigma0;
H2=hbar*k_x*nu1*sigmay-hbar*k_y*(s1*nu2*sigmax+kesi*v_m*sigma0+kesi*v_p*sigmaz)+DeltaSO*(alpha-s1*kesi)*sigmax+A*(s1*sigmaz-kesi*sigmax)+V*sigma0;
H3=hbar*k_x*nu1*sigmay-hbar*k_y*(s*nu2*sigmax+kesi1*v_m*sigma0+kesi1*v_p*sigmaz)+DeltaSO*(alpha-s*kesi1)*sigmax+A*(s*sigmaz-kesi1*sigmax)+V*sigma0;
H4=hbar*k_x*nu1*sigmay-hbar*k_y*(s1*nu2*sigmax+kesi1*v_m*sigma0+kesi1*v_p*sigmaz)+DeltaSO*(alpha-s1*kesi1)*sigmax+A*(s1*sigmaz-kesi1*sigmax)+V*sigma0;
[v1,E1]=eig(H1);
[v2,E2]=eig(H2);
[v3,E3]=eig(H3);
[v4,E4]=eig(H4);
KX(i,j)=k_x;
KY(i,j)=k_y;
sx(i,j)=v4(:,2)’*sigmax*v4(:,2);
sy(i,j)=v4(:,2)’*sigmay*v4(:,2);
end
end
quiver(KX,KY,sx,sy,1)
q.ShowArrowHead = ‘off’;
q.Marker = ‘o’;
Qu I wrote a code to have a quiver plot as I attached here. I want to add a colorbar to this code as it shows the magnitude of the vectors. How can I do that?
nu1=3.87e5;
nu2=0.46e5;
v_m=2.84e5;
v_p=7.18e5;
%
% nu1=8.4;
% nu2=1;
% v_m=1;
% v_p=2.5;
s=1;
s1=-1;
kesi=1;
kesi1=-1;
DeltaSO=41.9e-3;
alpha=1;
A=0.0;
hbar=1;
V=0;
iform=complex(0.0,1.0);
for i=1:25
k_x=-0.3+2*(i-1)*0.3/25;
for j=1:25
k_y=-0.3+2*(j-1)*0.3/25;
sigmax=[0 1; 1 0];
sigmay=[0 -iform; iform 0];
sigmaz=[1 0; 0 -1];
sigma0=[1 0; 0 1];
H1=hbar*k_x*nu1*sigmay-hbar*k_y*(s*nu2*sigmax+kesi*v_m*sigma0+kesi*v_p*sigmaz)+DeltaSO*(alpha-s*kesi)*sigmax+A*(s*sigmaz-kesi*sigmax)+V*sigma0;
H2=hbar*k_x*nu1*sigmay-hbar*k_y*(s1*nu2*sigmax+kesi*v_m*sigma0+kesi*v_p*sigmaz)+DeltaSO*(alpha-s1*kesi)*sigmax+A*(s1*sigmaz-kesi*sigmax)+V*sigma0;
H3=hbar*k_x*nu1*sigmay-hbar*k_y*(s*nu2*sigmax+kesi1*v_m*sigma0+kesi1*v_p*sigmaz)+DeltaSO*(alpha-s*kesi1)*sigmax+A*(s*sigmaz-kesi1*sigmax)+V*sigma0;
H4=hbar*k_x*nu1*sigmay-hbar*k_y*(s1*nu2*sigmax+kesi1*v_m*sigma0+kesi1*v_p*sigmaz)+DeltaSO*(alpha-s1*kesi1)*sigmax+A*(s1*sigmaz-kesi1*sigmax)+V*sigma0;
[v1,E1]=eig(H1);
[v2,E2]=eig(H2);
[v3,E3]=eig(H3);
[v4,E4]=eig(H4);
KX(i,j)=k_x;
KY(i,j)=k_y;
sx(i,j)=v4(:,2)’*sigmax*v4(:,2);
sy(i,j)=v4(:,2)’*sigmay*v4(:,2);
end
end
quiver(KX,KY,sx,sy,1)
q.ShowArrowHead = ‘off’;
q.Marker = ‘o’;
Qu quiver- colorbar MATLAB Answers — New Questions
Search is getting failed for a library usage in Simulink model
I wanted to search number of instances of a library being used in the entire simulink model and also wanted to know all the path where the library is being is used.
But it is not working and says "Search Failed"
I have already increased "Java Heap Memory" to MAX in preferences.
Also deleted all temp files from temp folder and restarted PC and Matlab,SI wanted to search number of instances of a library being used in the entire simulink model and also wanted to know all the path where the library is being is used.
But it is not working and says "Search Failed"
I have already increased "Java Heap Memory" to MAX in preferences.
Also deleted all temp files from temp folder and restarted PC and Matlab,S I wanted to search number of instances of a library being used in the entire simulink model and also wanted to know all the path where the library is being is used.
But it is not working and says "Search Failed"
I have already increased "Java Heap Memory" to MAX in preferences.
Also deleted all temp files from temp folder and restarted PC and Matlab,S matlab search MATLAB Answers — New Questions
How to plot AM/AM and AM/PM Characteristic using input and output baseband signals?
I have .txt files that contain complex input and output baseband signals of an amplifier. I need to plot the AM/AM (magnitude of Gain vs. Input power) and AM/PM (phase of Gain vs. Input power) Characteristic.
% Calculate input and output power
P_in = 30 + 10*log10( (abs(x_in).^2)/100); % x_in is the input baseband signal
P_out = 30 + 10*log10((abs(x_out).^2)/100); % x_out is the output baseband signal
% Calculate gain
Mag_Gain = P_out – P_in;
Phase_Gain = rad2deg((angle(x_out) – angle(x_in)));
% Then I plot the AM/AM and AM/PM curves
% however the results does not match with the theoretical results.
% Is the way for calculating the power correct?I have .txt files that contain complex input and output baseband signals of an amplifier. I need to plot the AM/AM (magnitude of Gain vs. Input power) and AM/PM (phase of Gain vs. Input power) Characteristic.
% Calculate input and output power
P_in = 30 + 10*log10( (abs(x_in).^2)/100); % x_in is the input baseband signal
P_out = 30 + 10*log10((abs(x_out).^2)/100); % x_out is the output baseband signal
% Calculate gain
Mag_Gain = P_out – P_in;
Phase_Gain = rad2deg((angle(x_out) – angle(x_in)));
% Then I plot the AM/AM and AM/PM curves
% however the results does not match with the theoretical results.
% Is the way for calculating the power correct? I have .txt files that contain complex input and output baseband signals of an amplifier. I need to plot the AM/AM (magnitude of Gain vs. Input power) and AM/PM (phase of Gain vs. Input power) Characteristic.
% Calculate input and output power
P_in = 30 + 10*log10( (abs(x_in).^2)/100); % x_in is the input baseband signal
P_out = 30 + 10*log10((abs(x_out).^2)/100); % x_out is the output baseband signal
% Calculate gain
Mag_Gain = P_out – P_in;
Phase_Gain = rad2deg((angle(x_out) – angle(x_in)));
% Then I plot the AM/AM and AM/PM curves
% however the results does not match with the theoretical results.
% Is the way for calculating the power correct? amplifier MATLAB Answers — New Questions