Category: Matlab
Category Archives: Matlab
how to use an integral function inside a for loop? i need to find the value of function that chages as i chages .then using this values i need to find another integral.
r0 =0.1
u =[1:7]’
Q =zeros(length(u),1)
E =zeros(length(Q),1)
for i =1:length(u)
Q(i,1) =0.023*(r0^(-1/4))*((u(i))^(-14/4))
f =@(Q) (Q(i)).^(0.3)
E(i,1) =integral(f,1,7)
endr0 =0.1
u =[1:7]’
Q =zeros(length(u),1)
E =zeros(length(Q),1)
for i =1:length(u)
Q(i,1) =0.023*(r0^(-1/4))*((u(i))^(-14/4))
f =@(Q) (Q(i)).^(0.3)
E(i,1) =integral(f,1,7)
end r0 =0.1
u =[1:7]’
Q =zeros(length(u),1)
E =zeros(length(Q),1)
for i =1:length(u)
Q(i,1) =0.023*(r0^(-1/4))*((u(i))^(-14/4))
f =@(Q) (Q(i)).^(0.3)
E(i,1) =integral(f,1,7)
end integral, for loop MATLAB Answers — New Questions
Error 5001 when trying to run Matlab 2021b.
…on Windows 7 "Unable to communicate with required MathWorks services"…on Windows 7 "Unable to communicate with required MathWorks services" …on Windows 7 "Unable to communicate with required MathWorks services" error, windows7 MATLAB Answers — New Questions
Output comparison of Analog vs Digital mems accelerometer
Analog vs. Digital MEMS Accelerometer Output Comparison
Hello,
We are developing a condition monitoring device and are currently testing its performance using the SPM Vib-15 as a reference, which is a well-known industrial condition monitoring device.
SPM Vib-15 Vibrameter (Analog Device) :
Link to datasheet: Here
Our Device with ST Accelerometer Sensor (IIS3DWB Digital Sensor):
Link to the datasheet: Here
IIS3DWB Configuration :
Accelerometer ODR: IIS3DWB_XL_ODR_26k7Hz
FIFO BDR: IIS3DWB_XL_BATCHED_AT_26k7Hz
Effective ODR: 26.9 kHz
Full Scale: ACCELERO_FS_16
Hardware Filter: IIS3DWB_HP_ODR_DIV_800
Issue :
We are measuring the acceleration RMS and velocity of a compressor/chiller/motor in an industrial setting during normal operation. Despite the IIS3DWB sensor providing output in all three axes, we are considering only the Y-axis, which aligns with the SPM Vib-15.
We have taken readings for acceleration peak, acceleration RMS, and speed RMS using both our device and the SPM Vib-15. However, our device’s readings are significantly different from those of the SPM Vib-15, particularly at higher vibration levels (almost double). The acceleration RMS values have been converted to G to match the units used by the vibrameter, and velocity RMS values are already in mm/s for both devices.
Problem :
Despite similar measurement conditions and proper mounting of both devices, our readings do not match the SPM Vib-15 readings. Given that both devices serve the same application, should we expect the digital sensor data from the IIS3DWB to closely align with the analog sensor output from the SPM Vib-15?
Are we making an error by comparing the outputs of an analog sensor to those of a digital sensor? What could be causing these discrepancies?
We have also attempted linear regression for calibration, but it did not resolve the issue.
Additional Information :
Images:
First from the right side is the SPM vibrameter, and last one (biggest one) is our device.
mounted in vertical direction
mounted in horizontal direction
(in this image at the center is our device)
the third device is for refference (blue one) , which has same sansor that we are using in our device.
Data brief of that device: https://www.st.com/resource/en/data_brief/steval-stwinkt1b.pdfAnalog vs. Digital MEMS Accelerometer Output Comparison
Hello,
We are developing a condition monitoring device and are currently testing its performance using the SPM Vib-15 as a reference, which is a well-known industrial condition monitoring device.
SPM Vib-15 Vibrameter (Analog Device) :
Link to datasheet: Here
Our Device with ST Accelerometer Sensor (IIS3DWB Digital Sensor):
Link to the datasheet: Here
IIS3DWB Configuration :
Accelerometer ODR: IIS3DWB_XL_ODR_26k7Hz
FIFO BDR: IIS3DWB_XL_BATCHED_AT_26k7Hz
Effective ODR: 26.9 kHz
Full Scale: ACCELERO_FS_16
Hardware Filter: IIS3DWB_HP_ODR_DIV_800
Issue :
We are measuring the acceleration RMS and velocity of a compressor/chiller/motor in an industrial setting during normal operation. Despite the IIS3DWB sensor providing output in all three axes, we are considering only the Y-axis, which aligns with the SPM Vib-15.
We have taken readings for acceleration peak, acceleration RMS, and speed RMS using both our device and the SPM Vib-15. However, our device’s readings are significantly different from those of the SPM Vib-15, particularly at higher vibration levels (almost double). The acceleration RMS values have been converted to G to match the units used by the vibrameter, and velocity RMS values are already in mm/s for both devices.
Problem :
Despite similar measurement conditions and proper mounting of both devices, our readings do not match the SPM Vib-15 readings. Given that both devices serve the same application, should we expect the digital sensor data from the IIS3DWB to closely align with the analog sensor output from the SPM Vib-15?
Are we making an error by comparing the outputs of an analog sensor to those of a digital sensor? What could be causing these discrepancies?
We have also attempted linear regression for calibration, but it did not resolve the issue.
Additional Information :
Images:
First from the right side is the SPM vibrameter, and last one (biggest one) is our device.
mounted in vertical direction
mounted in horizontal direction
(in this image at the center is our device)
the third device is for refference (blue one) , which has same sansor that we are using in our device.
Data brief of that device: https://www.st.com/resource/en/data_brief/steval-stwinkt1b.pdf Analog vs. Digital MEMS Accelerometer Output Comparison
Hello,
We are developing a condition monitoring device and are currently testing its performance using the SPM Vib-15 as a reference, which is a well-known industrial condition monitoring device.
SPM Vib-15 Vibrameter (Analog Device) :
Link to datasheet: Here
Our Device with ST Accelerometer Sensor (IIS3DWB Digital Sensor):
Link to the datasheet: Here
IIS3DWB Configuration :
Accelerometer ODR: IIS3DWB_XL_ODR_26k7Hz
FIFO BDR: IIS3DWB_XL_BATCHED_AT_26k7Hz
Effective ODR: 26.9 kHz
Full Scale: ACCELERO_FS_16
Hardware Filter: IIS3DWB_HP_ODR_DIV_800
Issue :
We are measuring the acceleration RMS and velocity of a compressor/chiller/motor in an industrial setting during normal operation. Despite the IIS3DWB sensor providing output in all three axes, we are considering only the Y-axis, which aligns with the SPM Vib-15.
We have taken readings for acceleration peak, acceleration RMS, and speed RMS using both our device and the SPM Vib-15. However, our device’s readings are significantly different from those of the SPM Vib-15, particularly at higher vibration levels (almost double). The acceleration RMS values have been converted to G to match the units used by the vibrameter, and velocity RMS values are already in mm/s for both devices.
Problem :
Despite similar measurement conditions and proper mounting of both devices, our readings do not match the SPM Vib-15 readings. Given that both devices serve the same application, should we expect the digital sensor data from the IIS3DWB to closely align with the analog sensor output from the SPM Vib-15?
Are we making an error by comparing the outputs of an analog sensor to those of a digital sensor? What could be causing these discrepancies?
We have also attempted linear regression for calibration, but it did not resolve the issue.
Additional Information :
Images:
First from the right side is the SPM vibrameter, and last one (biggest one) is our device.
mounted in vertical direction
mounted in horizontal direction
(in this image at the center is our device)
the third device is for refference (blue one) , which has same sansor that we are using in our device.
Data brief of that device: https://www.st.com/resource/en/data_brief/steval-stwinkt1b.pdf predictive_maintenance, condition_monitoring, spm_vib_15 MATLAB Answers — New Questions
Can I use quadprog solver in an Explicit MPC?
Hi,
I have a question regarding to using quadprog solver. Can I use quadprog solver to obtain all the regions for a Explicit MPC?
I have this in my code (thinking that maybe I can use quadprog solver)
% Generate explicit MPC controller
mpcobj.Optimizer.Solver = ‘interior-point’;
setCustomSolver(mpcobj,’quadprog’);
My other question is can I change the cost function that the Explicit MPC will minimize when it will obtain the controller? How?
Thanks in advance
DaveHi,
I have a question regarding to using quadprog solver. Can I use quadprog solver to obtain all the regions for a Explicit MPC?
I have this in my code (thinking that maybe I can use quadprog solver)
% Generate explicit MPC controller
mpcobj.Optimizer.Solver = ‘interior-point’;
setCustomSolver(mpcobj,’quadprog’);
My other question is can I change the cost function that the Explicit MPC will minimize when it will obtain the controller? How?
Thanks in advance
Dave Hi,
I have a question regarding to using quadprog solver. Can I use quadprog solver to obtain all the regions for a Explicit MPC?
I have this in my code (thinking that maybe I can use quadprog solver)
% Generate explicit MPC controller
mpcobj.Optimizer.Solver = ‘interior-point’;
setCustomSolver(mpcobj,’quadprog’);
My other question is can I change the cost function that the Explicit MPC will minimize when it will obtain the controller? How?
Thanks in advance
Dave mpc, explicit mpc, solve MATLAB Answers — New Questions
I am facing an issue while converting my OFDM code from matlab to HDL during fixed point conversion
This is my ofdm code , which simulates ofdm reciever and transmitter , over a rayleigh channel , using 16Qam modulation, with doppler.
function [BitsRx] = OfdmDopplerBer(~)
Rs = 54.64e5;
% Symbol Duration, [s]
Ts = 1/Rs;
% Carrier Frequency, [Hz]
f = 1.5e9;
% Modulation Order of QPSK by definition
M = 16;
% Number of Bits in QPSK Symbol
k = log2(M);
% QPSK Signal Bandwidth, [Hz]
F = 1/Ts;
% Number of Subcarriers (equal to Number of FFT points)
numSC = 1024;
%NumSymbols=3;
% Guard Bands Subcarriers
GuardBandSC = [10; 10];
% Central Null Subcarrier
DCNull = true;
DCNullSC = numSC/2 + 1;
% Number of Pilot Subcarriers
numPilotSC = 10;
PilotSC =[15 125 236 346 456 567 677 787 898 1008]’;
% Length of Cyclic Prefix
lenCP = numSC/4;
% OFDM Modulator Object
OFDMModulator = comm.OFDMModulator( …
‘FFTLength’, numSC, …
‘NumGuardBandCarriers’, GuardBandSC, …
‘Windowing’,true,…
‘InsertDCNull’, DCNull, …
‘PilotInputPort’, true, …
‘PilotCarrierIndices’, PilotSC, …
‘CyclicPrefixLength’, lenCP);
OFDMDemodulator = comm.OFDMDemodulator(OFDMModulator);
% Mapping of Subcarriers in Time-Frequency Space
%showResourceMapping(OFDMModulator)
% Number of Data Subcarriers
numDataSC = info(OFDMModulator).DataInputSize(1);
% Size of Data Frame
szDataFrame = [numDataSC 1];
% Size of Pilot Frame
szPilotFrame = info(OFDMModulator).PilotInputSize;
% OFDM Symbol Duration with Cyclic Prefix, [s]
Ts_OFDM = (numSC + lenCP)*Ts;
% OFDM Symbol Rate with Cyclic Prefix, [1/s]
Rs_OFDM = 1/Ts_OFDM;
% Decreasing of Symbol Rate by using OFDM
Rs/Rs_OFDM;
% Subcarrier Bandwidth, [Hz]
F_SC = F/numSC;
clear ans
% Discrete Paths Relative Delays, [s]
PathDelays = [0 3 5 6 11]*Ts ;
% Discrete Paths Max Delay, [s]
Tm = max(PathDelays);
% Channel Coherence Bandwidth [2, p. 960; 3, p. 399], [Hz]
Fc = 1/Tm;
% Discrete Paths Average Gains, [dB]
PathAvGains = [0 -8 -17 -21 -25];
% Discrete Paths K Factors
K = [0.1 0.1 0.1 0.1 0.1];
% Approximate Speed of Ionospheric Irregularities, [m/s]
v=170.14;
% Light Speed, [m/s]
c = 3e8;
% Max Doppler Frequency Shift for all Discrete Paths, [Hz]
fD = v*f/c;
% Channel Coherence Time [3, p. 400], [s]
Tc = 1/fD;
spsSync = 1;
norms = [1 sqrt(2) 0 sqrt(10) 0 sqrt(42)];
doppler1 = comm.PhaseFrequencyOffset( …
FrequencyOffset=fD, …
PhaseOffset=0, …
SampleRate=Rs);
varDelay = dsp.VariableFractionalDelay;
%% Rician Channel Object
RicianFadingChannel = comm.RicianChannel( …
‘SampleRate’, Rs, …
‘PathDelays’, PathDelays, …
‘AveragePathGains’, PathAvGains, …
‘NormalizePathGains’, true, …
‘KFactor’, K, …
‘MaximumDopplerShift’, fD, …
‘DirectPathDopplerShift’, zeros(size(K)), …
‘DirectPathInitialPhase’, zeros(size(K)), …
‘DopplerSpectrum’, doppler(‘Jakes’) …
);
% Delay in Channel Object, [sample]
ChanDelay = info(RicianFadingChannel).ChannelFilterDelay;
%% AWGN Channel Object
AWGNChannel = comm.AWGNChannel( …
‘NoiseMethod’, ‘Signal to noise ratio (SNR)’, …
‘SNR’, 0 …
);
% table(F, F_SC, Fc, fD, ‘VariableNames’, {‘F, [Hz]’, ‘F_SC, [Hz]’, ‘Fc, [Hz]’, ‘fD, [Hz]’})
% table(Ts, Ts_OFDM, Tm, Tc, ‘VariableNames’, {‘Ts, [s]’, ‘Ts_OFDM, [s]’, ‘Tm, [s]’, ‘Tc, [s]’})
% Range of Eb/N0
EbNo = 0:60;
% Number of Transmitted Frames
numFrames = 500;
% BER Calculators Object
BERCalculater = comm.ErrorRate;
% BER Variable for Imitation Modeling Result
BER = zeros(3,length(EbNo));
% Loop for the Range of Eb/N0
for n = 1:length(EbNo)
% Setting the Eb/No in AWGN Channel Object
AWGNChannel.SNR = EbNo(n) + 10*log10(k) + 10*log10(numDataSC/numSC);
% BER Calculation
reset(BERCalculater);
BERn = zeros(3,1);
% Loop for the Number of Transmitted Frames
for fr = 1:numFrames
% >>> Transmitter >>>
% Generation of Data Bits
BitsTx = randi([0 M-1], [szDataFrame,1]);
constellation = qammod(0:M-1, M, ‘gray’);
% Normalize the constellation
constellation = constellation / norms(k);
% Apply phase offset
% constellation = constellation * exp(1i * phaseOffset);
% Define General QAM Modulator with custom constellation
QAMModulator = comm.GeneralQAMModulator(‘Constellation’, constellation);
SignalTx1 = zeros(szDataFrame);
% Modulate the data symbols
SignalTx1 = QAMModulator(BitsTx);
% Generation of Pilot Signals
PilotSignalTx = complex(ones(szPilotFrame), zeros(szPilotFrame));
% OFDM Modulation
SignalTx2 = OFDMModulator(SignalTx1, PilotSignalTx);
% Power of Transmitted Signal
% Compute the power of the transmitted signal
SignalTxPower = sum(abs(SignalTx2).^2) / length(SignalTx2);
% Adding zero samples to the end of Transmitted Signal
% to not lose shifted samples caused by delay after Rician Channel
SignalTx2 = [SignalTx2; zeros(ChanDelay, 1)];
%SignalTx2_with_pfo = pfo(SignalTx2);
%%
% Rician Channel
SignalChan1 = RicianFadingChannel(SignalTx2);
% Removing first ChanDelay samples and
% selection of Channel’s Signal related to Transmitted Signal
SignalChan1 = SignalChan1(ChanDelay + 1 : end);
%% introducing the delay in frequency and symbol time due to doppler
txDoppler = doppler1(SignalChan1);
txDelay = varDelay(txDoppler, fr/numFrames);
SignalChan3=txDelay;
%%
% AWGN Channel
AWGNChannel.SignalPower = SignalTxPower;
SignalChan2 = AWGNChannel(SignalChan3);
% >>> Receiver >>>
% OFDM Demodulation
[SignalRx1, PilotSignalRx] = OFDMDemodulator(SignalChan2);
%%
% LS Channel Estimation
% Obtaining discrete points of Channel Frequency Response
% based on dividing the Received Pilot Signals by the known ones
ChanFR_dp = PilotSignalRx ./ PilotSignalTx;
% Interpolation of Channel Frequency Response
% ChanFR_int = zeros(numSC, 1); % Preallocate the result array
ChanFR_int = fixed.interp1( …
PilotSC, …
ChanFR_dp, …
GuardBandSC(1) + 1 : numSC – GuardBandSC(2), …
‘linear’ …
);
% Selection of Data Subcarriers components of Frequency Response
% by cutting out components of Pilot and DC Subcarriers
% Remove components of Pilot and DC Subcarriers
ChanFR_int([PilotSC; DCNullSC] – GuardBandSC(1)) = [];
% LS Solution
SignalRx2 = SignalRx1./ ChanFR_int.’;
% 2. Denormalize the signal
SignalRx2 = SignalRx2* norms(k);
QAMDemodulator = comm.GeneralQAMDemodulator(‘Constellation’,…
qammod(0:M-1, M, ‘gray’));
% Demodulate the received signal
BitsRx = QAMDemodulator(SignalRx2);
%BitsRx = qamdemod(SignalRx2*sqrt(10),M,"gray");
% BER Calculation
BERn = BERCalculater(BitsTx, BitsRx);
end
% BER Results
BER(:,n) = BERn;
end
clear n fr BERn
disp(BitsRx);
end
I am trying to convert this code to hdl, but am facing this error in the fixed point conversion part
Expected input 1 to have fixed dimensions for System object comm.OFDMModulator.
refering to this line
SignalTx2 = OFDMModulator(SignalTx1, PilotSignalTx);
Can someone help with this ?This is my ofdm code , which simulates ofdm reciever and transmitter , over a rayleigh channel , using 16Qam modulation, with doppler.
function [BitsRx] = OfdmDopplerBer(~)
Rs = 54.64e5;
% Symbol Duration, [s]
Ts = 1/Rs;
% Carrier Frequency, [Hz]
f = 1.5e9;
% Modulation Order of QPSK by definition
M = 16;
% Number of Bits in QPSK Symbol
k = log2(M);
% QPSK Signal Bandwidth, [Hz]
F = 1/Ts;
% Number of Subcarriers (equal to Number of FFT points)
numSC = 1024;
%NumSymbols=3;
% Guard Bands Subcarriers
GuardBandSC = [10; 10];
% Central Null Subcarrier
DCNull = true;
DCNullSC = numSC/2 + 1;
% Number of Pilot Subcarriers
numPilotSC = 10;
PilotSC =[15 125 236 346 456 567 677 787 898 1008]’;
% Length of Cyclic Prefix
lenCP = numSC/4;
% OFDM Modulator Object
OFDMModulator = comm.OFDMModulator( …
‘FFTLength’, numSC, …
‘NumGuardBandCarriers’, GuardBandSC, …
‘Windowing’,true,…
‘InsertDCNull’, DCNull, …
‘PilotInputPort’, true, …
‘PilotCarrierIndices’, PilotSC, …
‘CyclicPrefixLength’, lenCP);
OFDMDemodulator = comm.OFDMDemodulator(OFDMModulator);
% Mapping of Subcarriers in Time-Frequency Space
%showResourceMapping(OFDMModulator)
% Number of Data Subcarriers
numDataSC = info(OFDMModulator).DataInputSize(1);
% Size of Data Frame
szDataFrame = [numDataSC 1];
% Size of Pilot Frame
szPilotFrame = info(OFDMModulator).PilotInputSize;
% OFDM Symbol Duration with Cyclic Prefix, [s]
Ts_OFDM = (numSC + lenCP)*Ts;
% OFDM Symbol Rate with Cyclic Prefix, [1/s]
Rs_OFDM = 1/Ts_OFDM;
% Decreasing of Symbol Rate by using OFDM
Rs/Rs_OFDM;
% Subcarrier Bandwidth, [Hz]
F_SC = F/numSC;
clear ans
% Discrete Paths Relative Delays, [s]
PathDelays = [0 3 5 6 11]*Ts ;
% Discrete Paths Max Delay, [s]
Tm = max(PathDelays);
% Channel Coherence Bandwidth [2, p. 960; 3, p. 399], [Hz]
Fc = 1/Tm;
% Discrete Paths Average Gains, [dB]
PathAvGains = [0 -8 -17 -21 -25];
% Discrete Paths K Factors
K = [0.1 0.1 0.1 0.1 0.1];
% Approximate Speed of Ionospheric Irregularities, [m/s]
v=170.14;
% Light Speed, [m/s]
c = 3e8;
% Max Doppler Frequency Shift for all Discrete Paths, [Hz]
fD = v*f/c;
% Channel Coherence Time [3, p. 400], [s]
Tc = 1/fD;
spsSync = 1;
norms = [1 sqrt(2) 0 sqrt(10) 0 sqrt(42)];
doppler1 = comm.PhaseFrequencyOffset( …
FrequencyOffset=fD, …
PhaseOffset=0, …
SampleRate=Rs);
varDelay = dsp.VariableFractionalDelay;
%% Rician Channel Object
RicianFadingChannel = comm.RicianChannel( …
‘SampleRate’, Rs, …
‘PathDelays’, PathDelays, …
‘AveragePathGains’, PathAvGains, …
‘NormalizePathGains’, true, …
‘KFactor’, K, …
‘MaximumDopplerShift’, fD, …
‘DirectPathDopplerShift’, zeros(size(K)), …
‘DirectPathInitialPhase’, zeros(size(K)), …
‘DopplerSpectrum’, doppler(‘Jakes’) …
);
% Delay in Channel Object, [sample]
ChanDelay = info(RicianFadingChannel).ChannelFilterDelay;
%% AWGN Channel Object
AWGNChannel = comm.AWGNChannel( …
‘NoiseMethod’, ‘Signal to noise ratio (SNR)’, …
‘SNR’, 0 …
);
% table(F, F_SC, Fc, fD, ‘VariableNames’, {‘F, [Hz]’, ‘F_SC, [Hz]’, ‘Fc, [Hz]’, ‘fD, [Hz]’})
% table(Ts, Ts_OFDM, Tm, Tc, ‘VariableNames’, {‘Ts, [s]’, ‘Ts_OFDM, [s]’, ‘Tm, [s]’, ‘Tc, [s]’})
% Range of Eb/N0
EbNo = 0:60;
% Number of Transmitted Frames
numFrames = 500;
% BER Calculators Object
BERCalculater = comm.ErrorRate;
% BER Variable for Imitation Modeling Result
BER = zeros(3,length(EbNo));
% Loop for the Range of Eb/N0
for n = 1:length(EbNo)
% Setting the Eb/No in AWGN Channel Object
AWGNChannel.SNR = EbNo(n) + 10*log10(k) + 10*log10(numDataSC/numSC);
% BER Calculation
reset(BERCalculater);
BERn = zeros(3,1);
% Loop for the Number of Transmitted Frames
for fr = 1:numFrames
% >>> Transmitter >>>
% Generation of Data Bits
BitsTx = randi([0 M-1], [szDataFrame,1]);
constellation = qammod(0:M-1, M, ‘gray’);
% Normalize the constellation
constellation = constellation / norms(k);
% Apply phase offset
% constellation = constellation * exp(1i * phaseOffset);
% Define General QAM Modulator with custom constellation
QAMModulator = comm.GeneralQAMModulator(‘Constellation’, constellation);
SignalTx1 = zeros(szDataFrame);
% Modulate the data symbols
SignalTx1 = QAMModulator(BitsTx);
% Generation of Pilot Signals
PilotSignalTx = complex(ones(szPilotFrame), zeros(szPilotFrame));
% OFDM Modulation
SignalTx2 = OFDMModulator(SignalTx1, PilotSignalTx);
% Power of Transmitted Signal
% Compute the power of the transmitted signal
SignalTxPower = sum(abs(SignalTx2).^2) / length(SignalTx2);
% Adding zero samples to the end of Transmitted Signal
% to not lose shifted samples caused by delay after Rician Channel
SignalTx2 = [SignalTx2; zeros(ChanDelay, 1)];
%SignalTx2_with_pfo = pfo(SignalTx2);
%%
% Rician Channel
SignalChan1 = RicianFadingChannel(SignalTx2);
% Removing first ChanDelay samples and
% selection of Channel’s Signal related to Transmitted Signal
SignalChan1 = SignalChan1(ChanDelay + 1 : end);
%% introducing the delay in frequency and symbol time due to doppler
txDoppler = doppler1(SignalChan1);
txDelay = varDelay(txDoppler, fr/numFrames);
SignalChan3=txDelay;
%%
% AWGN Channel
AWGNChannel.SignalPower = SignalTxPower;
SignalChan2 = AWGNChannel(SignalChan3);
% >>> Receiver >>>
% OFDM Demodulation
[SignalRx1, PilotSignalRx] = OFDMDemodulator(SignalChan2);
%%
% LS Channel Estimation
% Obtaining discrete points of Channel Frequency Response
% based on dividing the Received Pilot Signals by the known ones
ChanFR_dp = PilotSignalRx ./ PilotSignalTx;
% Interpolation of Channel Frequency Response
% ChanFR_int = zeros(numSC, 1); % Preallocate the result array
ChanFR_int = fixed.interp1( …
PilotSC, …
ChanFR_dp, …
GuardBandSC(1) + 1 : numSC – GuardBandSC(2), …
‘linear’ …
);
% Selection of Data Subcarriers components of Frequency Response
% by cutting out components of Pilot and DC Subcarriers
% Remove components of Pilot and DC Subcarriers
ChanFR_int([PilotSC; DCNullSC] – GuardBandSC(1)) = [];
% LS Solution
SignalRx2 = SignalRx1./ ChanFR_int.’;
% 2. Denormalize the signal
SignalRx2 = SignalRx2* norms(k);
QAMDemodulator = comm.GeneralQAMDemodulator(‘Constellation’,…
qammod(0:M-1, M, ‘gray’));
% Demodulate the received signal
BitsRx = QAMDemodulator(SignalRx2);
%BitsRx = qamdemod(SignalRx2*sqrt(10),M,"gray");
% BER Calculation
BERn = BERCalculater(BitsTx, BitsRx);
end
% BER Results
BER(:,n) = BERn;
end
clear n fr BERn
disp(BitsRx);
end
I am trying to convert this code to hdl, but am facing this error in the fixed point conversion part
Expected input 1 to have fixed dimensions for System object comm.OFDMModulator.
refering to this line
SignalTx2 = OFDMModulator(SignalTx1, PilotSignalTx);
Can someone help with this ? This is my ofdm code , which simulates ofdm reciever and transmitter , over a rayleigh channel , using 16Qam modulation, with doppler.
function [BitsRx] = OfdmDopplerBer(~)
Rs = 54.64e5;
% Symbol Duration, [s]
Ts = 1/Rs;
% Carrier Frequency, [Hz]
f = 1.5e9;
% Modulation Order of QPSK by definition
M = 16;
% Number of Bits in QPSK Symbol
k = log2(M);
% QPSK Signal Bandwidth, [Hz]
F = 1/Ts;
% Number of Subcarriers (equal to Number of FFT points)
numSC = 1024;
%NumSymbols=3;
% Guard Bands Subcarriers
GuardBandSC = [10; 10];
% Central Null Subcarrier
DCNull = true;
DCNullSC = numSC/2 + 1;
% Number of Pilot Subcarriers
numPilotSC = 10;
PilotSC =[15 125 236 346 456 567 677 787 898 1008]’;
% Length of Cyclic Prefix
lenCP = numSC/4;
% OFDM Modulator Object
OFDMModulator = comm.OFDMModulator( …
‘FFTLength’, numSC, …
‘NumGuardBandCarriers’, GuardBandSC, …
‘Windowing’,true,…
‘InsertDCNull’, DCNull, …
‘PilotInputPort’, true, …
‘PilotCarrierIndices’, PilotSC, …
‘CyclicPrefixLength’, lenCP);
OFDMDemodulator = comm.OFDMDemodulator(OFDMModulator);
% Mapping of Subcarriers in Time-Frequency Space
%showResourceMapping(OFDMModulator)
% Number of Data Subcarriers
numDataSC = info(OFDMModulator).DataInputSize(1);
% Size of Data Frame
szDataFrame = [numDataSC 1];
% Size of Pilot Frame
szPilotFrame = info(OFDMModulator).PilotInputSize;
% OFDM Symbol Duration with Cyclic Prefix, [s]
Ts_OFDM = (numSC + lenCP)*Ts;
% OFDM Symbol Rate with Cyclic Prefix, [1/s]
Rs_OFDM = 1/Ts_OFDM;
% Decreasing of Symbol Rate by using OFDM
Rs/Rs_OFDM;
% Subcarrier Bandwidth, [Hz]
F_SC = F/numSC;
clear ans
% Discrete Paths Relative Delays, [s]
PathDelays = [0 3 5 6 11]*Ts ;
% Discrete Paths Max Delay, [s]
Tm = max(PathDelays);
% Channel Coherence Bandwidth [2, p. 960; 3, p. 399], [Hz]
Fc = 1/Tm;
% Discrete Paths Average Gains, [dB]
PathAvGains = [0 -8 -17 -21 -25];
% Discrete Paths K Factors
K = [0.1 0.1 0.1 0.1 0.1];
% Approximate Speed of Ionospheric Irregularities, [m/s]
v=170.14;
% Light Speed, [m/s]
c = 3e8;
% Max Doppler Frequency Shift for all Discrete Paths, [Hz]
fD = v*f/c;
% Channel Coherence Time [3, p. 400], [s]
Tc = 1/fD;
spsSync = 1;
norms = [1 sqrt(2) 0 sqrt(10) 0 sqrt(42)];
doppler1 = comm.PhaseFrequencyOffset( …
FrequencyOffset=fD, …
PhaseOffset=0, …
SampleRate=Rs);
varDelay = dsp.VariableFractionalDelay;
%% Rician Channel Object
RicianFadingChannel = comm.RicianChannel( …
‘SampleRate’, Rs, …
‘PathDelays’, PathDelays, …
‘AveragePathGains’, PathAvGains, …
‘NormalizePathGains’, true, …
‘KFactor’, K, …
‘MaximumDopplerShift’, fD, …
‘DirectPathDopplerShift’, zeros(size(K)), …
‘DirectPathInitialPhase’, zeros(size(K)), …
‘DopplerSpectrum’, doppler(‘Jakes’) …
);
% Delay in Channel Object, [sample]
ChanDelay = info(RicianFadingChannel).ChannelFilterDelay;
%% AWGN Channel Object
AWGNChannel = comm.AWGNChannel( …
‘NoiseMethod’, ‘Signal to noise ratio (SNR)’, …
‘SNR’, 0 …
);
% table(F, F_SC, Fc, fD, ‘VariableNames’, {‘F, [Hz]’, ‘F_SC, [Hz]’, ‘Fc, [Hz]’, ‘fD, [Hz]’})
% table(Ts, Ts_OFDM, Tm, Tc, ‘VariableNames’, {‘Ts, [s]’, ‘Ts_OFDM, [s]’, ‘Tm, [s]’, ‘Tc, [s]’})
% Range of Eb/N0
EbNo = 0:60;
% Number of Transmitted Frames
numFrames = 500;
% BER Calculators Object
BERCalculater = comm.ErrorRate;
% BER Variable for Imitation Modeling Result
BER = zeros(3,length(EbNo));
% Loop for the Range of Eb/N0
for n = 1:length(EbNo)
% Setting the Eb/No in AWGN Channel Object
AWGNChannel.SNR = EbNo(n) + 10*log10(k) + 10*log10(numDataSC/numSC);
% BER Calculation
reset(BERCalculater);
BERn = zeros(3,1);
% Loop for the Number of Transmitted Frames
for fr = 1:numFrames
% >>> Transmitter >>>
% Generation of Data Bits
BitsTx = randi([0 M-1], [szDataFrame,1]);
constellation = qammod(0:M-1, M, ‘gray’);
% Normalize the constellation
constellation = constellation / norms(k);
% Apply phase offset
% constellation = constellation * exp(1i * phaseOffset);
% Define General QAM Modulator with custom constellation
QAMModulator = comm.GeneralQAMModulator(‘Constellation’, constellation);
SignalTx1 = zeros(szDataFrame);
% Modulate the data symbols
SignalTx1 = QAMModulator(BitsTx);
% Generation of Pilot Signals
PilotSignalTx = complex(ones(szPilotFrame), zeros(szPilotFrame));
% OFDM Modulation
SignalTx2 = OFDMModulator(SignalTx1, PilotSignalTx);
% Power of Transmitted Signal
% Compute the power of the transmitted signal
SignalTxPower = sum(abs(SignalTx2).^2) / length(SignalTx2);
% Adding zero samples to the end of Transmitted Signal
% to not lose shifted samples caused by delay after Rician Channel
SignalTx2 = [SignalTx2; zeros(ChanDelay, 1)];
%SignalTx2_with_pfo = pfo(SignalTx2);
%%
% Rician Channel
SignalChan1 = RicianFadingChannel(SignalTx2);
% Removing first ChanDelay samples and
% selection of Channel’s Signal related to Transmitted Signal
SignalChan1 = SignalChan1(ChanDelay + 1 : end);
%% introducing the delay in frequency and symbol time due to doppler
txDoppler = doppler1(SignalChan1);
txDelay = varDelay(txDoppler, fr/numFrames);
SignalChan3=txDelay;
%%
% AWGN Channel
AWGNChannel.SignalPower = SignalTxPower;
SignalChan2 = AWGNChannel(SignalChan3);
% >>> Receiver >>>
% OFDM Demodulation
[SignalRx1, PilotSignalRx] = OFDMDemodulator(SignalChan2);
%%
% LS Channel Estimation
% Obtaining discrete points of Channel Frequency Response
% based on dividing the Received Pilot Signals by the known ones
ChanFR_dp = PilotSignalRx ./ PilotSignalTx;
% Interpolation of Channel Frequency Response
% ChanFR_int = zeros(numSC, 1); % Preallocate the result array
ChanFR_int = fixed.interp1( …
PilotSC, …
ChanFR_dp, …
GuardBandSC(1) + 1 : numSC – GuardBandSC(2), …
‘linear’ …
);
% Selection of Data Subcarriers components of Frequency Response
% by cutting out components of Pilot and DC Subcarriers
% Remove components of Pilot and DC Subcarriers
ChanFR_int([PilotSC; DCNullSC] – GuardBandSC(1)) = [];
% LS Solution
SignalRx2 = SignalRx1./ ChanFR_int.’;
% 2. Denormalize the signal
SignalRx2 = SignalRx2* norms(k);
QAMDemodulator = comm.GeneralQAMDemodulator(‘Constellation’,…
qammod(0:M-1, M, ‘gray’));
% Demodulate the received signal
BitsRx = QAMDemodulator(SignalRx2);
%BitsRx = qamdemod(SignalRx2*sqrt(10),M,"gray");
% BER Calculation
BERn = BERCalculater(BitsTx, BitsRx);
end
% BER Results
BER(:,n) = BERn;
end
clear n fr BERn
disp(BitsRx);
end
I am trying to convert this code to hdl, but am facing this error in the fixed point conversion part
Expected input 1 to have fixed dimensions for System object comm.OFDMModulator.
refering to this line
SignalTx2 = OFDMModulator(SignalTx1, PilotSignalTx);
Can someone help with this ? ofdm, doppler, rayleigh channel MATLAB Answers — New Questions
How can I use ginput in app designer?
I would like to select a range of points from one particular UIAxes in my app.
I have tried to use ginput ([x,y=ginput]), but the applications prompts an additional empty plot to select the range of points. How can I point an specific UIAxes?
Kind RegardsI would like to select a range of points from one particular UIAxes in my app.
I have tried to use ginput ([x,y=ginput]), but the applications prompts an additional empty plot to select the range of points. How can I point an specific UIAxes?
Kind Regards I would like to select a range of points from one particular UIAxes in my app.
I have tried to use ginput ([x,y=ginput]), but the applications prompts an additional empty plot to select the range of points. How can I point an specific UIAxes?
Kind Regards ginput app MATLAB Answers — New Questions
How to define an array based on Simulink simulation time?
Hello everyone, I’m attempting to define an array in a MATLAB Function block based on the simulation time in Simulink. In my code, I use ‘times index’ to record the number of simulation steps. I have set the time step to 0.01s.To achieve this goal, I used ‘persistent’ variables, but encountered an error. How can I implement my objective?
function [y,y1] = fcn(u)
persistent inputs; % 声明一个持久变量用于保存输入值
persistent time_index;
if isempty(inputs) % 如果持久变量为空,则初始化
inputs = u; % 将当前输入值保存到持久变量中
time_index = 1;
else
inputs = [inputs, u]; % 将当前输入值追加到持久变量中
time_index = time_index + 1;
end
% 计算平均值
mean_val = mean(inputs);
% 计算差值的平方
diff_squared = (inputs – mean_val).^2;
% 计算方差
y = sum(diff_squared) / length(inputs);
all_inputs(time_index) = u;
y1=all_inputs;
This is the error I encountered.Hello everyone, I’m attempting to define an array in a MATLAB Function block based on the simulation time in Simulink. In my code, I use ‘times index’ to record the number of simulation steps. I have set the time step to 0.01s.To achieve this goal, I used ‘persistent’ variables, but encountered an error. How can I implement my objective?
function [y,y1] = fcn(u)
persistent inputs; % 声明一个持久变量用于保存输入值
persistent time_index;
if isempty(inputs) % 如果持久变量为空,则初始化
inputs = u; % 将当前输入值保存到持久变量中
time_index = 1;
else
inputs = [inputs, u]; % 将当前输入值追加到持久变量中
time_index = time_index + 1;
end
% 计算平均值
mean_val = mean(inputs);
% 计算差值的平方
diff_squared = (inputs – mean_val).^2;
% 计算方差
y = sum(diff_squared) / length(inputs);
all_inputs(time_index) = u;
y1=all_inputs;
This is the error I encountered. Hello everyone, I’m attempting to define an array in a MATLAB Function block based on the simulation time in Simulink. In my code, I use ‘times index’ to record the number of simulation steps. I have set the time step to 0.01s.To achieve this goal, I used ‘persistent’ variables, but encountered an error. How can I implement my objective?
function [y,y1] = fcn(u)
persistent inputs; % 声明一个持久变量用于保存输入值
persistent time_index;
if isempty(inputs) % 如果持久变量为空,则初始化
inputs = u; % 将当前输入值保存到持久变量中
time_index = 1;
else
inputs = [inputs, u]; % 将当前输入值追加到持久变量中
time_index = time_index + 1;
end
% 计算平均值
mean_val = mean(inputs);
% 计算差值的平方
diff_squared = (inputs – mean_val).^2;
% 计算方差
y = sum(diff_squared) / length(inputs);
all_inputs(time_index) = u;
y1=all_inputs;
This is the error I encountered. simulink, matlab function, array define MATLAB Answers — New Questions
Geographical binning with HISTA not creating squares
Hello everybody!
My data contains latitude, longitute, time and multiple other variables. I need to bin this data for my needs.
>> head(w_files{1})
time lon lat pci_lte sinr_lte cinr_lte rsrp_lte prb_dl_lte prb_ul_lte bler_dl_lte bler_ul_lte mod_dl_0_lte mod_dl_1_lte mod_ul_lte earfnc_dl_lte earfnc_ul_lte tp_mac_dl_lte tp_mac_ul_lte tp_pdsch_lte tp_pusch_lte tp_pdcp_dl_lte tp_pdcp_ul_lte tm tx_rx bw_dl_lte bw_ul_lte band ca_dl ca_ul ca_comb
_______________________ ______ ______ _______ ________ ________ ________ __________ __________ ___________ ___________ ____________ ____________ __________ _____________ _____________ _____________ _____________ ____________ ____________ ______________ ______________ __________ _____________ _________ _________ ___________ __________ __________ _________________________
2020-12-08 11:48:13.000 14.563 50.035 NaN NaN 0 NaN NaN NaN NaN NaN {0×0 char} {0×0 char} {0×0 char} NaN NaN NaN NaN NaN NaN NaN NaN {0×0 char} {0×0 char } NaN NaN {0×0 char } {0×0 char} {0×0 char} {0×0 char }
2020-12-08 11:48:14.000 14.563 50.035 374 NaN 0 -61 41.49 0.74 9 5 {‘256QAM’} {0×0 char} {0×0 char} 6200 24200 238.43 0.002 238.43 0.327 0 0 {‘TM4’ } {‘MIMO(4×2)’} 10 10 {‘Band 20’} {‘3CA’ } {‘NonCA’ } {‘Band 20+Band 7+Band 3’}
2020-12-08 11:48:15.000 14.563 50.035 374 11 0 -61 43.3 0.7 7 2 {‘256QAM’} {0×0 char} {0×0 char} 6200 24200 256.08 0.002 256.08 0.314 0 0 {‘TM4’ } {‘MIMO(4×2)’} 10 10 {‘Band 20’} {‘3CA’ } {‘NonCA’ } {‘Band 20+Band 7+Band 3’}
2020-12-08 11:48:16.000 14.563 50.035 374 10 0 -61 44.31 0.69 6 2 {‘256QAM’} {0×0 char} {0×0 char} 6200 24200 257.2 0.001 257.2 0.324 0 0 {‘TM4’ } {‘MIMO(4×2)’} 10 10 {‘Band 20’} {‘3CA’ } {‘NonCA’ } {‘Band 20+Band 7+Band 3’}
2020-12-08 11:48:17.000 14.563 50.035 374 10 0 -61 43.57 0.81 6 0 {‘256QAM’} {0×0 char} {0×0 char} 6200 24200 252.94 0.001 252.94 0.357 0 0 {‘TM4’ } {‘MIMO(4×2)’} 10 10 {‘Band 20’} {‘3CA’ } {‘NonCA’ } {‘Band 20+Band 7+Band 3’}
2020-12-08 11:48:18.000 14.563 50.035 374 9 0 -63 44.93 0.79 7 0 {’64QAM’ } {0×0 char} {0×0 char} 6200 24200 226.24 0.002 226.24 0.35 0 0 {‘TM4’ } {‘MIMO(4×2)’} 10 10 {‘Band 20’} {‘3CA’ } {‘NonCA’ } {‘Band 20+Band 7+Band 3’}
2020-12-08 11:48:19.000 14.563 50.035 374 7 0 -62 44.45 0.8 11 0 {’16QAM’ } {0×0 char} {0×0 char} 6200 24200 191.17 0.002 191.17 0.359 0 0 {‘TM4’ } {‘MIMO(4×2)’} 10 10 {‘Band 20’} {‘3CA’ } {‘NonCA’ } {‘Band 20+Band 7+Band 3’}
2020-12-08 11:48:20.000 14.563 50.035 374 2 0 -66 44.18 0.82 12 2 {’16QAM’ } {0×0 char} {0×0 char} 6200 24200 177.6 0.002 177.6 0.372 0 0 {‘TM4’ } {‘MIMO(4×2)’} 10 10 {‘Band 20’} {‘3CA’ } {‘NonCA’ } {‘Band 20+Band 7+Band 3’}
I am using HISTA to find a 20×20 meters grid and applying it on the data sets.
[latbin, lonbin] = hista(w_files{ii}.lat,w_files{ii}.lon,0.0004);% bin at 20x20m,hista binning + computing binsID
[w_files{ii}.latEq, w_files{ii}.lonEq] = grn2eqa(w_files{ii}.lat,w_files{ii}.lon);% Convert coordinates to equidistant cartesian coordinates
[latbinEq, lonbinEq] = grn2eqa(latbin, lonbin);% Convert coordinates to equidistant cartesian coordinates
dist = pdist2([w_files{ii}.lonEq,w_files{ii}.latEq],[lonbinEq, latbinEq]);% Compute distance between each coordinate and each bin-center
[~, w_files{ii}.bin20] = min(dist,[],2);% Add bin ID numbers to table
When I run a figure with plot_google_map I am not getting squares but rectangles. Right now, I am not sure if I am just displaying it wrong or I have made some mistake in the binning. I have added one sample file for you guys to try. (You will need plot_google_map function to have the map picture but this issue is clearly visible without it as well).
figure()
hold on
scatter(lonbin, latbin, 200, 1:numel(lonbin), ‘Marker’,’*’,’LineWidth’,2) % bin centers
scatter(w_files{ii}.lon,w_files{ii}.lat, 50,w_files{ii}.bin20,’filled’)
cmap = colorcube(255);
colormap(cmap(1:end-10,:))
xlabel(‘longitude’); ylabel(‘latitude’)
latbinUnq = unique(latbin);
lonbinUnq = unique(lonbin);
set(gca, ‘xtick’, lonbinUnq(2:end)-diff(lonbinUnq)/2,’ytick’,latbinUnq(2:end)-diff(latbinUnq)/2)
grid on
plot_google_map(‘Scale’,2,’resize’,2,’ShowLabels’,0)%google_plot settings
What do you think? If you think you know the answer, please be very specific because I am a beginner and I might be dumb.Hello everybody!
My data contains latitude, longitute, time and multiple other variables. I need to bin this data for my needs.
>> head(w_files{1})
time lon lat pci_lte sinr_lte cinr_lte rsrp_lte prb_dl_lte prb_ul_lte bler_dl_lte bler_ul_lte mod_dl_0_lte mod_dl_1_lte mod_ul_lte earfnc_dl_lte earfnc_ul_lte tp_mac_dl_lte tp_mac_ul_lte tp_pdsch_lte tp_pusch_lte tp_pdcp_dl_lte tp_pdcp_ul_lte tm tx_rx bw_dl_lte bw_ul_lte band ca_dl ca_ul ca_comb
_______________________ ______ ______ _______ ________ ________ ________ __________ __________ ___________ ___________ ____________ ____________ __________ _____________ _____________ _____________ _____________ ____________ ____________ ______________ ______________ __________ _____________ _________ _________ ___________ __________ __________ _________________________
2020-12-08 11:48:13.000 14.563 50.035 NaN NaN 0 NaN NaN NaN NaN NaN {0×0 char} {0×0 char} {0×0 char} NaN NaN NaN NaN NaN NaN NaN NaN {0×0 char} {0×0 char } NaN NaN {0×0 char } {0×0 char} {0×0 char} {0×0 char }
2020-12-08 11:48:14.000 14.563 50.035 374 NaN 0 -61 41.49 0.74 9 5 {‘256QAM’} {0×0 char} {0×0 char} 6200 24200 238.43 0.002 238.43 0.327 0 0 {‘TM4’ } {‘MIMO(4×2)’} 10 10 {‘Band 20’} {‘3CA’ } {‘NonCA’ } {‘Band 20+Band 7+Band 3’}
2020-12-08 11:48:15.000 14.563 50.035 374 11 0 -61 43.3 0.7 7 2 {‘256QAM’} {0×0 char} {0×0 char} 6200 24200 256.08 0.002 256.08 0.314 0 0 {‘TM4’ } {‘MIMO(4×2)’} 10 10 {‘Band 20’} {‘3CA’ } {‘NonCA’ } {‘Band 20+Band 7+Band 3’}
2020-12-08 11:48:16.000 14.563 50.035 374 10 0 -61 44.31 0.69 6 2 {‘256QAM’} {0×0 char} {0×0 char} 6200 24200 257.2 0.001 257.2 0.324 0 0 {‘TM4’ } {‘MIMO(4×2)’} 10 10 {‘Band 20’} {‘3CA’ } {‘NonCA’ } {‘Band 20+Band 7+Band 3’}
2020-12-08 11:48:17.000 14.563 50.035 374 10 0 -61 43.57 0.81 6 0 {‘256QAM’} {0×0 char} {0×0 char} 6200 24200 252.94 0.001 252.94 0.357 0 0 {‘TM4’ } {‘MIMO(4×2)’} 10 10 {‘Band 20’} {‘3CA’ } {‘NonCA’ } {‘Band 20+Band 7+Band 3’}
2020-12-08 11:48:18.000 14.563 50.035 374 9 0 -63 44.93 0.79 7 0 {’64QAM’ } {0×0 char} {0×0 char} 6200 24200 226.24 0.002 226.24 0.35 0 0 {‘TM4’ } {‘MIMO(4×2)’} 10 10 {‘Band 20’} {‘3CA’ } {‘NonCA’ } {‘Band 20+Band 7+Band 3’}
2020-12-08 11:48:19.000 14.563 50.035 374 7 0 -62 44.45 0.8 11 0 {’16QAM’ } {0×0 char} {0×0 char} 6200 24200 191.17 0.002 191.17 0.359 0 0 {‘TM4’ } {‘MIMO(4×2)’} 10 10 {‘Band 20’} {‘3CA’ } {‘NonCA’ } {‘Band 20+Band 7+Band 3’}
2020-12-08 11:48:20.000 14.563 50.035 374 2 0 -66 44.18 0.82 12 2 {’16QAM’ } {0×0 char} {0×0 char} 6200 24200 177.6 0.002 177.6 0.372 0 0 {‘TM4’ } {‘MIMO(4×2)’} 10 10 {‘Band 20’} {‘3CA’ } {‘NonCA’ } {‘Band 20+Band 7+Band 3’}
I am using HISTA to find a 20×20 meters grid and applying it on the data sets.
[latbin, lonbin] = hista(w_files{ii}.lat,w_files{ii}.lon,0.0004);% bin at 20x20m,hista binning + computing binsID
[w_files{ii}.latEq, w_files{ii}.lonEq] = grn2eqa(w_files{ii}.lat,w_files{ii}.lon);% Convert coordinates to equidistant cartesian coordinates
[latbinEq, lonbinEq] = grn2eqa(latbin, lonbin);% Convert coordinates to equidistant cartesian coordinates
dist = pdist2([w_files{ii}.lonEq,w_files{ii}.latEq],[lonbinEq, latbinEq]);% Compute distance between each coordinate and each bin-center
[~, w_files{ii}.bin20] = min(dist,[],2);% Add bin ID numbers to table
When I run a figure with plot_google_map I am not getting squares but rectangles. Right now, I am not sure if I am just displaying it wrong or I have made some mistake in the binning. I have added one sample file for you guys to try. (You will need plot_google_map function to have the map picture but this issue is clearly visible without it as well).
figure()
hold on
scatter(lonbin, latbin, 200, 1:numel(lonbin), ‘Marker’,’*’,’LineWidth’,2) % bin centers
scatter(w_files{ii}.lon,w_files{ii}.lat, 50,w_files{ii}.bin20,’filled’)
cmap = colorcube(255);
colormap(cmap(1:end-10,:))
xlabel(‘longitude’); ylabel(‘latitude’)
latbinUnq = unique(latbin);
lonbinUnq = unique(lonbin);
set(gca, ‘xtick’, lonbinUnq(2:end)-diff(lonbinUnq)/2,’ytick’,latbinUnq(2:end)-diff(latbinUnq)/2)
grid on
plot_google_map(‘Scale’,2,’resize’,2,’ShowLabels’,0)%google_plot settings
What do you think? If you think you know the answer, please be very specific because I am a beginner and I might be dumb. Hello everybody!
My data contains latitude, longitute, time and multiple other variables. I need to bin this data for my needs.
>> head(w_files{1})
time lon lat pci_lte sinr_lte cinr_lte rsrp_lte prb_dl_lte prb_ul_lte bler_dl_lte bler_ul_lte mod_dl_0_lte mod_dl_1_lte mod_ul_lte earfnc_dl_lte earfnc_ul_lte tp_mac_dl_lte tp_mac_ul_lte tp_pdsch_lte tp_pusch_lte tp_pdcp_dl_lte tp_pdcp_ul_lte tm tx_rx bw_dl_lte bw_ul_lte band ca_dl ca_ul ca_comb
_______________________ ______ ______ _______ ________ ________ ________ __________ __________ ___________ ___________ ____________ ____________ __________ _____________ _____________ _____________ _____________ ____________ ____________ ______________ ______________ __________ _____________ _________ _________ ___________ __________ __________ _________________________
2020-12-08 11:48:13.000 14.563 50.035 NaN NaN 0 NaN NaN NaN NaN NaN {0×0 char} {0×0 char} {0×0 char} NaN NaN NaN NaN NaN NaN NaN NaN {0×0 char} {0×0 char } NaN NaN {0×0 char } {0×0 char} {0×0 char} {0×0 char }
2020-12-08 11:48:14.000 14.563 50.035 374 NaN 0 -61 41.49 0.74 9 5 {‘256QAM’} {0×0 char} {0×0 char} 6200 24200 238.43 0.002 238.43 0.327 0 0 {‘TM4’ } {‘MIMO(4×2)’} 10 10 {‘Band 20’} {‘3CA’ } {‘NonCA’ } {‘Band 20+Band 7+Band 3’}
2020-12-08 11:48:15.000 14.563 50.035 374 11 0 -61 43.3 0.7 7 2 {‘256QAM’} {0×0 char} {0×0 char} 6200 24200 256.08 0.002 256.08 0.314 0 0 {‘TM4’ } {‘MIMO(4×2)’} 10 10 {‘Band 20’} {‘3CA’ } {‘NonCA’ } {‘Band 20+Band 7+Band 3’}
2020-12-08 11:48:16.000 14.563 50.035 374 10 0 -61 44.31 0.69 6 2 {‘256QAM’} {0×0 char} {0×0 char} 6200 24200 257.2 0.001 257.2 0.324 0 0 {‘TM4’ } {‘MIMO(4×2)’} 10 10 {‘Band 20’} {‘3CA’ } {‘NonCA’ } {‘Band 20+Band 7+Band 3’}
2020-12-08 11:48:17.000 14.563 50.035 374 10 0 -61 43.57 0.81 6 0 {‘256QAM’} {0×0 char} {0×0 char} 6200 24200 252.94 0.001 252.94 0.357 0 0 {‘TM4’ } {‘MIMO(4×2)’} 10 10 {‘Band 20’} {‘3CA’ } {‘NonCA’ } {‘Band 20+Band 7+Band 3’}
2020-12-08 11:48:18.000 14.563 50.035 374 9 0 -63 44.93 0.79 7 0 {’64QAM’ } {0×0 char} {0×0 char} 6200 24200 226.24 0.002 226.24 0.35 0 0 {‘TM4’ } {‘MIMO(4×2)’} 10 10 {‘Band 20’} {‘3CA’ } {‘NonCA’ } {‘Band 20+Band 7+Band 3’}
2020-12-08 11:48:19.000 14.563 50.035 374 7 0 -62 44.45 0.8 11 0 {’16QAM’ } {0×0 char} {0×0 char} 6200 24200 191.17 0.002 191.17 0.359 0 0 {‘TM4’ } {‘MIMO(4×2)’} 10 10 {‘Band 20’} {‘3CA’ } {‘NonCA’ } {‘Band 20+Band 7+Band 3’}
2020-12-08 11:48:20.000 14.563 50.035 374 2 0 -66 44.18 0.82 12 2 {’16QAM’ } {0×0 char} {0×0 char} 6200 24200 177.6 0.002 177.6 0.372 0 0 {‘TM4’ } {‘MIMO(4×2)’} 10 10 {‘Band 20’} {‘3CA’ } {‘NonCA’ } {‘Band 20+Band 7+Band 3’}
I am using HISTA to find a 20×20 meters grid and applying it on the data sets.
[latbin, lonbin] = hista(w_files{ii}.lat,w_files{ii}.lon,0.0004);% bin at 20x20m,hista binning + computing binsID
[w_files{ii}.latEq, w_files{ii}.lonEq] = grn2eqa(w_files{ii}.lat,w_files{ii}.lon);% Convert coordinates to equidistant cartesian coordinates
[latbinEq, lonbinEq] = grn2eqa(latbin, lonbin);% Convert coordinates to equidistant cartesian coordinates
dist = pdist2([w_files{ii}.lonEq,w_files{ii}.latEq],[lonbinEq, latbinEq]);% Compute distance between each coordinate and each bin-center
[~, w_files{ii}.bin20] = min(dist,[],2);% Add bin ID numbers to table
When I run a figure with plot_google_map I am not getting squares but rectangles. Right now, I am not sure if I am just displaying it wrong or I have made some mistake in the binning. I have added one sample file for you guys to try. (You will need plot_google_map function to have the map picture but this issue is clearly visible without it as well).
figure()
hold on
scatter(lonbin, latbin, 200, 1:numel(lonbin), ‘Marker’,’*’,’LineWidth’,2) % bin centers
scatter(w_files{ii}.lon,w_files{ii}.lat, 50,w_files{ii}.bin20,’filled’)
cmap = colorcube(255);
colormap(cmap(1:end-10,:))
xlabel(‘longitude’); ylabel(‘latitude’)
latbinUnq = unique(latbin);
lonbinUnq = unique(lonbin);
set(gca, ‘xtick’, lonbinUnq(2:end)-diff(lonbinUnq)/2,’ytick’,latbinUnq(2:end)-diff(latbinUnq)/2)
grid on
plot_google_map(‘Scale’,2,’resize’,2,’ShowLabels’,0)%google_plot settings
What do you think? If you think you know the answer, please be very specific because I am a beginner and I might be dumb. hista, geographical binning, plotting map MATLAB Answers — New Questions
I want to modify the code to plot the Lagrange polynomial interpolation with Chebyshev points. Map the n+ 1 Chebyshev interpolation points from [-1,1] to [2,3]
clear
n = 3; % the order of the polynomial
a = 2.0; % left end of the interval
b = 3.0; % right end of the interval
h = (b – a)/n; % interpolation grid size
t = a:h:b; % interpolation points
f = 1./t; % f(x) = 1./x, This is the function evaluated at interpolation points
%%%% pn(x) = sum f(t_i)l_i(x)
hh = 0.01; % grid to plot the function both f and p
x = a:hh:b;
fexact = 1./x; %exact function f at x
l = zeros(n+1, length(x)); %%%% l(1,:): l_0(x), …, l(n+1): l_n(x)
nn = ones(n+1, length(x));
d = ones(n + 1, length(x));
for i = 1:n+1
for j = 1:length(x)
nn(i,j) = 1;
d(i,j) = 1;
for k = 1:n+1
if i ~= k
nn(i,j) = nn(i,j) * (x(j) – t(k));
d(i,j) = d(i,j) * (t(i) – t(k));
end
end
l(i,j) = nn(i,j)/d(i,j);
end
end
fapp = zeros(length(x),1);
for j = 1:length(x)
for i=1:n+1
fapp(j) = fapp(j) + f(i)*l(i,j);
end
end
En = 0;
Ed = 0;
for i = 1:length(x)
Ed = Ed + fexact(i)^2;
En = En + (fexact(i) – fapp(i))^2;
end
Ed = sqrt(Ed);
En = sqrt(En);
E = En/Ed;
display(E)
plot(x,fexact,’b*-‘)
hold on
plot(x,fapp,’ro-‘ )clear
n = 3; % the order of the polynomial
a = 2.0; % left end of the interval
b = 3.0; % right end of the interval
h = (b – a)/n; % interpolation grid size
t = a:h:b; % interpolation points
f = 1./t; % f(x) = 1./x, This is the function evaluated at interpolation points
%%%% pn(x) = sum f(t_i)l_i(x)
hh = 0.01; % grid to plot the function both f and p
x = a:hh:b;
fexact = 1./x; %exact function f at x
l = zeros(n+1, length(x)); %%%% l(1,:): l_0(x), …, l(n+1): l_n(x)
nn = ones(n+1, length(x));
d = ones(n + 1, length(x));
for i = 1:n+1
for j = 1:length(x)
nn(i,j) = 1;
d(i,j) = 1;
for k = 1:n+1
if i ~= k
nn(i,j) = nn(i,j) * (x(j) – t(k));
d(i,j) = d(i,j) * (t(i) – t(k));
end
end
l(i,j) = nn(i,j)/d(i,j);
end
end
fapp = zeros(length(x),1);
for j = 1:length(x)
for i=1:n+1
fapp(j) = fapp(j) + f(i)*l(i,j);
end
end
En = 0;
Ed = 0;
for i = 1:length(x)
Ed = Ed + fexact(i)^2;
En = En + (fexact(i) – fapp(i))^2;
end
Ed = sqrt(Ed);
En = sqrt(En);
E = En/Ed;
display(E)
plot(x,fexact,’b*-‘)
hold on
plot(x,fapp,’ro-‘ ) clear
n = 3; % the order of the polynomial
a = 2.0; % left end of the interval
b = 3.0; % right end of the interval
h = (b – a)/n; % interpolation grid size
t = a:h:b; % interpolation points
f = 1./t; % f(x) = 1./x, This is the function evaluated at interpolation points
%%%% pn(x) = sum f(t_i)l_i(x)
hh = 0.01; % grid to plot the function both f and p
x = a:hh:b;
fexact = 1./x; %exact function f at x
l = zeros(n+1, length(x)); %%%% l(1,:): l_0(x), …, l(n+1): l_n(x)
nn = ones(n+1, length(x));
d = ones(n + 1, length(x));
for i = 1:n+1
for j = 1:length(x)
nn(i,j) = 1;
d(i,j) = 1;
for k = 1:n+1
if i ~= k
nn(i,j) = nn(i,j) * (x(j) – t(k));
d(i,j) = d(i,j) * (t(i) – t(k));
end
end
l(i,j) = nn(i,j)/d(i,j);
end
end
fapp = zeros(length(x),1);
for j = 1:length(x)
for i=1:n+1
fapp(j) = fapp(j) + f(i)*l(i,j);
end
end
En = 0;
Ed = 0;
for i = 1:length(x)
Ed = Ed + fexact(i)^2;
En = En + (fexact(i) – fapp(i))^2;
end
Ed = sqrt(Ed);
En = sqrt(En);
E = En/Ed;
display(E)
plot(x,fexact,’b*-‘)
hold on
plot(x,fapp,’ro-‘ ) chebyshev, points MATLAB Answers — New Questions
Simulink Requirement Editor: Indentation of Requirements upon importing them from Excel
I want to import Requirements from an Excel File in the Requirements Editor of Simulink (2018a). I would like to be able to "group", or unfold/collapse requirements according to their topic, as it is shown in the example "Migrating Requirements Management Interface Data to Simulink® Requirements™" (https://ch.mathworks.com/help/slrequirements/examples/_mw_f304f626-0b76-4fbf-a313-1ab233014a0b.html) when requirements are imported from a word file (where apparently Bookmarks are recognized for that).
Is there a way to import requirements from excel, in order to have them in a collapsible structure in the Requirement editor? I have tried the REGEX way where I specified a regex expression for the unique Req IDs (IDs are recognized correctly, i.e. they turn red in the newly opened excel file that appears when pressing "Preview", and after the last item in a line there’s a green item added, which I assume is a line termination item), but the mechanics behind when a new collapsible item is created is a bit shady to me.
Are named Excel cells the way to go? If yes, what’s the strategy?
Thanks for your help!
StefanI want to import Requirements from an Excel File in the Requirements Editor of Simulink (2018a). I would like to be able to "group", or unfold/collapse requirements according to their topic, as it is shown in the example "Migrating Requirements Management Interface Data to Simulink® Requirements™" (https://ch.mathworks.com/help/slrequirements/examples/_mw_f304f626-0b76-4fbf-a313-1ab233014a0b.html) when requirements are imported from a word file (where apparently Bookmarks are recognized for that).
Is there a way to import requirements from excel, in order to have them in a collapsible structure in the Requirement editor? I have tried the REGEX way where I specified a regex expression for the unique Req IDs (IDs are recognized correctly, i.e. they turn red in the newly opened excel file that appears when pressing "Preview", and after the last item in a line there’s a green item added, which I assume is a line termination item), but the mechanics behind when a new collapsible item is created is a bit shady to me.
Are named Excel cells the way to go? If yes, what’s the strategy?
Thanks for your help!
Stefan I want to import Requirements from an Excel File in the Requirements Editor of Simulink (2018a). I would like to be able to "group", or unfold/collapse requirements according to their topic, as it is shown in the example "Migrating Requirements Management Interface Data to Simulink® Requirements™" (https://ch.mathworks.com/help/slrequirements/examples/_mw_f304f626-0b76-4fbf-a313-1ab233014a0b.html) when requirements are imported from a word file (where apparently Bookmarks are recognized for that).
Is there a way to import requirements from excel, in order to have them in a collapsible structure in the Requirement editor? I have tried the REGEX way where I specified a regex expression for the unique Req IDs (IDs are recognized correctly, i.e. they turn red in the newly opened excel file that appears when pressing "Preview", and after the last item in a line there’s a green item added, which I assume is a line termination item), but the mechanics behind when a new collapsible item is created is a bit shady to me.
Are named Excel cells the way to go? If yes, what’s the strategy?
Thanks for your help!
Stefan requiremens editor, simulink, import excel requirements, 2018a, regex MATLAB Answers — New Questions
Can I get user email addresses from license server checkout/checkin log?
Hello,
I would like to find a way to get the email address of users of the MATLAB client software whenever they checkout/checkin a software license. Looking at the current software license log for FlexLM, I only see the system name registered for checkout/checkin events. Can you please tell me if there is a way to also include the user’s email address in the log?
Thank you,
-brianHello,
I would like to find a way to get the email address of users of the MATLAB client software whenever they checkout/checkin a software license. Looking at the current software license log for FlexLM, I only see the system name registered for checkout/checkin events. Can you please tell me if there is a way to also include the user’s email address in the log?
Thank you,
-brian Hello,
I would like to find a way to get the email address of users of the MATLAB client software whenever they checkout/checkin a software license. Looking at the current software license log for FlexLM, I only see the system name registered for checkout/checkin events. Can you please tell me if there is a way to also include the user’s email address in the log?
Thank you,
-brian license, checkout, user email MATLAB Answers — New Questions
What are the payment options for Training Classes?
What are the payment options for Training Classes?What are the payment options for Training Classes? What are the payment options for Training Classes? training, payment MATLAB Answers — New Questions
Still waiting for my order to be processed
Dear sirs,
i am still waiting for my order to be processed. I am frankly quite disapointed that it has not been processed. I decided to join you after some investigation. Please help expedite my order and send me details.
Best regards
Pálmi Ragnar PéturssonDear sirs,
i am still waiting for my order to be processed. I am frankly quite disapointed that it has not been processed. I decided to join you after some investigation. Please help expedite my order and send me details.
Best regards
Pálmi Ragnar Pétursson Dear sirs,
i am still waiting for my order to be processed. I am frankly quite disapointed that it has not been processed. I decided to join you after some investigation. Please help expedite my order and send me details.
Best regards
Pálmi Ragnar Pétursson thingspeak MATLAB Answers — New Questions
Training a TCN model to predict a Continuous Variable
Hello there, I am trying to build a TCN model to predict a continuous variable. Similar the the example here: https://www.mathworks.com/help/deeplearning/ug/sequence-to-sequence-classification-using-1-d-convolutions.html#SeqToSeqClassificationUsing1DConvAndModelFunctionExample-11. I have time series data in which I am using 3 input features (accelrometer measuments in x,y,z directions), but instead of classifying an acitivity, I am trying to estimate/predict a continuous variable. My predictors/input features are stored in a 10×1 cell array name "IMUdata" (each cell is one of the 10 trials) with each cell containing a 540×3 double with the acclerometer data from that trial. The target continous varable I am trying to predict is simialrly stored in a 10×1 cell array with each cell contaning a 540×1 double named "Predvar". The code I have been trying so far is:
numfeatures = 3;
numFilters = 64;
filterSize = 5;
droupoutFactor = 0.005;
numBlocks = 4;
net = dlnetwork;
layer = sequenceInputLayer(numFeatures,Normalization="rescale-symmetric",Name="input");
net = addLayers(net,layer);
outputName = layer.Name;
for i = 1:numBlocks
dilationFactor = 2^(i-1);
layers = [
convolution1dLayer(filterSize,numFilters,DilationFactor=dilationFactor,Padding="causal",Name="conv1_"+i)
layerNormalizationLayer
spatialDropoutLayer(Name= "spat_drop_"+i,Probability=droupoutFactor)
convolution1dLayer(filterSize,numFilters,DilationFactor=dilationFactor,Padding="causal")
layerNormalizationLayer
reluLayer
spatialDropoutLayer(Name="spat_drop2_"+i,Probability=droupoutFactor)
additionLayer(2,Name="add_"+i)];
% Add and connect layers.
net = addLayers(net,layers);
net = connectLayers(net,outputName,"conv1_"+i);
% Skip connection.
if i == 1
% Include convolution in first skip connection.
layer = convolution1dLayer(1,numFilters,Name="convSkip");
net = addLayers(net,layer);
net = connectLayers(net,outputName,"convSkip");
net = connectLayers(net,"convSkip","add_" + i + "/in2");
else
net = connectLayers(net,outputName,"add_" + i + "/in2");
end
% Update layer output name.
outputName = "add_" + i;
end
layers = [
fullyConnectedLayer(1)];
net = addLayers(net,layers);
net = connectLayers(net,outputName,"fc");
options = trainingOptions("adam", …
MaxEpochs=60, …
miniBatchSize=1, …
InputDataFormats="CTB", …
Plots="training-progress", …
Metrics="rmse", …
Verbose=0);
net = trainnet(IMUdata,Predvar,net,"mse",options)
However I am getiting an ERROR with the trainnet function saying that: Error setting data statistics of layer "input".nnet.cnn.layer.SequenceInputLayer>iAssertValidStatistics (line 341)Expected input to be of size 3×1, but it is of size 541×1.
Is this because of the way my input data is stored? Im not sure how to fix this error and if this is the correct way to build a TCN model to predict a continuous variable? Any help is greatly appreciated!Hello there, I am trying to build a TCN model to predict a continuous variable. Similar the the example here: https://www.mathworks.com/help/deeplearning/ug/sequence-to-sequence-classification-using-1-d-convolutions.html#SeqToSeqClassificationUsing1DConvAndModelFunctionExample-11. I have time series data in which I am using 3 input features (accelrometer measuments in x,y,z directions), but instead of classifying an acitivity, I am trying to estimate/predict a continuous variable. My predictors/input features are stored in a 10×1 cell array name "IMUdata" (each cell is one of the 10 trials) with each cell containing a 540×3 double with the acclerometer data from that trial. The target continous varable I am trying to predict is simialrly stored in a 10×1 cell array with each cell contaning a 540×1 double named "Predvar". The code I have been trying so far is:
numfeatures = 3;
numFilters = 64;
filterSize = 5;
droupoutFactor = 0.005;
numBlocks = 4;
net = dlnetwork;
layer = sequenceInputLayer(numFeatures,Normalization="rescale-symmetric",Name="input");
net = addLayers(net,layer);
outputName = layer.Name;
for i = 1:numBlocks
dilationFactor = 2^(i-1);
layers = [
convolution1dLayer(filterSize,numFilters,DilationFactor=dilationFactor,Padding="causal",Name="conv1_"+i)
layerNormalizationLayer
spatialDropoutLayer(Name= "spat_drop_"+i,Probability=droupoutFactor)
convolution1dLayer(filterSize,numFilters,DilationFactor=dilationFactor,Padding="causal")
layerNormalizationLayer
reluLayer
spatialDropoutLayer(Name="spat_drop2_"+i,Probability=droupoutFactor)
additionLayer(2,Name="add_"+i)];
% Add and connect layers.
net = addLayers(net,layers);
net = connectLayers(net,outputName,"conv1_"+i);
% Skip connection.
if i == 1
% Include convolution in first skip connection.
layer = convolution1dLayer(1,numFilters,Name="convSkip");
net = addLayers(net,layer);
net = connectLayers(net,outputName,"convSkip");
net = connectLayers(net,"convSkip","add_" + i + "/in2");
else
net = connectLayers(net,outputName,"add_" + i + "/in2");
end
% Update layer output name.
outputName = "add_" + i;
end
layers = [
fullyConnectedLayer(1)];
net = addLayers(net,layers);
net = connectLayers(net,outputName,"fc");
options = trainingOptions("adam", …
MaxEpochs=60, …
miniBatchSize=1, …
InputDataFormats="CTB", …
Plots="training-progress", …
Metrics="rmse", …
Verbose=0);
net = trainnet(IMUdata,Predvar,net,"mse",options)
However I am getiting an ERROR with the trainnet function saying that: Error setting data statistics of layer "input".nnet.cnn.layer.SequenceInputLayer>iAssertValidStatistics (line 341)Expected input to be of size 3×1, but it is of size 541×1.
Is this because of the way my input data is stored? Im not sure how to fix this error and if this is the correct way to build a TCN model to predict a continuous variable? Any help is greatly appreciated! Hello there, I am trying to build a TCN model to predict a continuous variable. Similar the the example here: https://www.mathworks.com/help/deeplearning/ug/sequence-to-sequence-classification-using-1-d-convolutions.html#SeqToSeqClassificationUsing1DConvAndModelFunctionExample-11. I have time series data in which I am using 3 input features (accelrometer measuments in x,y,z directions), but instead of classifying an acitivity, I am trying to estimate/predict a continuous variable. My predictors/input features are stored in a 10×1 cell array name "IMUdata" (each cell is one of the 10 trials) with each cell containing a 540×3 double with the acclerometer data from that trial. The target continous varable I am trying to predict is simialrly stored in a 10×1 cell array with each cell contaning a 540×1 double named "Predvar". The code I have been trying so far is:
numfeatures = 3;
numFilters = 64;
filterSize = 5;
droupoutFactor = 0.005;
numBlocks = 4;
net = dlnetwork;
layer = sequenceInputLayer(numFeatures,Normalization="rescale-symmetric",Name="input");
net = addLayers(net,layer);
outputName = layer.Name;
for i = 1:numBlocks
dilationFactor = 2^(i-1);
layers = [
convolution1dLayer(filterSize,numFilters,DilationFactor=dilationFactor,Padding="causal",Name="conv1_"+i)
layerNormalizationLayer
spatialDropoutLayer(Name= "spat_drop_"+i,Probability=droupoutFactor)
convolution1dLayer(filterSize,numFilters,DilationFactor=dilationFactor,Padding="causal")
layerNormalizationLayer
reluLayer
spatialDropoutLayer(Name="spat_drop2_"+i,Probability=droupoutFactor)
additionLayer(2,Name="add_"+i)];
% Add and connect layers.
net = addLayers(net,layers);
net = connectLayers(net,outputName,"conv1_"+i);
% Skip connection.
if i == 1
% Include convolution in first skip connection.
layer = convolution1dLayer(1,numFilters,Name="convSkip");
net = addLayers(net,layer);
net = connectLayers(net,outputName,"convSkip");
net = connectLayers(net,"convSkip","add_" + i + "/in2");
else
net = connectLayers(net,outputName,"add_" + i + "/in2");
end
% Update layer output name.
outputName = "add_" + i;
end
layers = [
fullyConnectedLayer(1)];
net = addLayers(net,layers);
net = connectLayers(net,outputName,"fc");
options = trainingOptions("adam", …
MaxEpochs=60, …
miniBatchSize=1, …
InputDataFormats="CTB", …
Plots="training-progress", …
Metrics="rmse", …
Verbose=0);
net = trainnet(IMUdata,Predvar,net,"mse",options)
However I am getiting an ERROR with the trainnet function saying that: Error setting data statistics of layer "input".nnet.cnn.layer.SequenceInputLayer>iAssertValidStatistics (line 341)Expected input to be of size 3×1, but it is of size 541×1.
Is this because of the way my input data is stored? Im not sure how to fix this error and if this is the correct way to build a TCN model to predict a continuous variable? Any help is greatly appreciated! tcn model, trainnet function, machine learning, neural networks MATLAB Answers — New Questions
Flipping Sign provide wrong information and Answers
Hi, I type my equation and the equation reversing and change the meaning of the equation.
can you assists me how to solve this? how to turn off the alphabetical orders settings?Hi, I type my equation and the equation reversing and change the meaning of the equation.
can you assists me how to solve this? how to turn off the alphabetical orders settings? Hi, I type my equation and the equation reversing and change the meaning of the equation.
can you assists me how to solve this? how to turn off the alphabetical orders settings? flipping sign, reversing equation MATLAB Answers — New Questions
Pressure interpolation CFD to FEA
Hello,
I have a 3D pressure distribution in the form of x,y,z and pressure coefficient at each node. I also have the FEA grid in the form of x,y,z of each node. I would like to interpolate the pressure from the CFD grid to the FEA grid. How do I do that please? ThanksHello,
I have a 3D pressure distribution in the form of x,y,z and pressure coefficient at each node. I also have the FEA grid in the form of x,y,z of each node. I would like to interpolate the pressure from the CFD grid to the FEA grid. How do I do that please? Thanks Hello,
I have a 3D pressure distribution in the form of x,y,z and pressure coefficient at each node. I also have the FEA grid in the form of x,y,z of each node. I would like to interpolate the pressure from the CFD grid to the FEA grid. How do I do that please? Thanks pressure interpolation MATLAB Answers — New Questions
lambda in fmincon Interior-Point Algorithm with Analytic Hessian
I am trying to use fmincon Interior-Point Algorithm with Analytic Hessian (https://www.mathworks.com/help/optim/ug/fmincon-interior-point-algorithm-with-analytic-hessian.html)
The examplay function is hessinterior which is Hessian of both c(1) and c(2).
My understanding is lambda is Lagrange Multiplier, which should be an output since it is the stationary points of the Lagrangian function. How come it is an input to the function hessinterior?
Thank you very much!I am trying to use fmincon Interior-Point Algorithm with Analytic Hessian (https://www.mathworks.com/help/optim/ug/fmincon-interior-point-algorithm-with-analytic-hessian.html)
The examplay function is hessinterior which is Hessian of both c(1) and c(2).
My understanding is lambda is Lagrange Multiplier, which should be an output since it is the stationary points of the Lagrangian function. How come it is an input to the function hessinterior?
Thank you very much! I am trying to use fmincon Interior-Point Algorithm with Analytic Hessian (https://www.mathworks.com/help/optim/ug/fmincon-interior-point-algorithm-with-analytic-hessian.html)
The examplay function is hessinterior which is Hessian of both c(1) and c(2).
My understanding is lambda is Lagrange Multiplier, which should be an output since it is the stationary points of the Lagrangian function. How come it is an input to the function hessinterior?
Thank you very much! fmincon, lambda MATLAB Answers — New Questions
How to add every nth element of an array to the nth+1 element?
I wonder if there is a short expression for the task above. For example if I had an array like this
a = [1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9]
How can I add, let’s say every 3rd element to every 4th element to get an array like this ?
a = [1, 2, 3+3, 4, 5+5, 6, 7+7, 8, 9]
I can do this with some ugle lines of code, but what if you got a more elegant way?I wonder if there is a short expression for the task above. For example if I had an array like this
a = [1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9]
How can I add, let’s say every 3rd element to every 4th element to get an array like this ?
a = [1, 2, 3+3, 4, 5+5, 6, 7+7, 8, 9]
I can do this with some ugle lines of code, but what if you got a more elegant way? I wonder if there is a short expression for the task above. For example if I had an array like this
a = [1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9]
How can I add, let’s say every 3rd element to every 4th element to get an array like this ?
a = [1, 2, 3+3, 4, 5+5, 6, 7+7, 8, 9]
I can do this with some ugle lines of code, but what if you got a more elegant way? arrays MATLAB Answers — New Questions
Why does the “interpolate” function have a large normalized volatility?
When using the "interpolate" function in the Financial Toolbox to simulate a Brown Bridge, the interpolated values have a much larger normalized volatility than the original time series. Ideally, the interpolated annualized daily return volatility should be similar to the original annual volatility. Why does the "interpolate" function have such a large normalized volatility?When using the "interpolate" function in the Financial Toolbox to simulate a Brown Bridge, the interpolated values have a much larger normalized volatility than the original time series. Ideally, the interpolated annualized daily return volatility should be similar to the original annual volatility. Why does the "interpolate" function have such a large normalized volatility? When using the "interpolate" function in the Financial Toolbox to simulate a Brown Bridge, the interpolated values have a much larger normalized volatility than the original time series. Ideally, the interpolated annualized daily return volatility should be similar to the original annual volatility. Why does the "interpolate" function have such a large normalized volatility? interpolate, "brown, bridge", volatility, brown, brownian, interpolation MATLAB Answers — New Questions
How to solve a fourth order differential equation (boundary value problem) with constraint?
Hi everyone,
I was trying to solve the following fourth order differential equation: A·x-B·x·w””(x)=w(x) where A and B are constants,and 0<x<l, and the boundary conditions are w(0) = 0, w”(l) = 0, w”'(l)=0, w””(0)=0. I solved the equation with bvp4c.
Now I want to add constratin to w””(x), i.e., 0<w””(x)<C, where C is a constant.
How can I add this constraint?
Thanks,
JZHi everyone,
I was trying to solve the following fourth order differential equation: A·x-B·x·w””(x)=w(x) where A and B are constants,and 0<x<l, and the boundary conditions are w(0) = 0, w”(l) = 0, w”'(l)=0, w””(0)=0. I solved the equation with bvp4c.
Now I want to add constratin to w””(x), i.e., 0<w””(x)<C, where C is a constant.
How can I add this constraint?
Thanks,
JZ Hi everyone,
I was trying to solve the following fourth order differential equation: A·x-B·x·w””(x)=w(x) where A and B are constants,and 0<x<l, and the boundary conditions are w(0) = 0, w”(l) = 0, w”'(l)=0, w””(0)=0. I solved the equation with bvp4c.
Now I want to add constratin to w””(x), i.e., 0<w””(x)<C, where C is a constant.
How can I add this constraint?
Thanks,
JZ differential equations MATLAB Answers — New Questions