Category: Matlab
Category Archives: Matlab
How can I stop the MathWorks Service Host from running on startup?
How can I stop the MathWorks Service Host from running on startup?How can I stop the MathWorks Service Host from running on startup? How can I stop the MathWorks Service Host from running on startup? mathworks-startup-host MATLAB Answers — New Questions
cpsd output vector differs from plotted result
When using cpsd to calculate the cross power spectral density, I’ve noticed that the plot produced by directly running the command with no output arguments is slightly different from what I get when I run it with an output argument and plot that output myself.
The following code (attached along with example signal file) produces the figure below.
signalx = randn(2e4,1);
signaly = randn(2e4,1);
window = length(signalx)/3;
noverlap = round(0.9*window);
fs = 2074;
[Pxy,F] = cpsd(signalx,signaly,window,noverlap,[],fs);
plot(F./1000,10.*log10(real(Pxy)))
hold on
cpsd(signalx,signaly,window,noverlap,[],fs);
legend(‘CPSD output’,’CPSD direct plot’)
I’m trying to run cpsd column-wise on a pair of very large matrices. Obviously I can’t just plot them one by one, but I don’t know how to interpret this difference and I’m not sure if I trust the output argument. Does anyone know what’s going on here? Thanks!When using cpsd to calculate the cross power spectral density, I’ve noticed that the plot produced by directly running the command with no output arguments is slightly different from what I get when I run it with an output argument and plot that output myself.
The following code (attached along with example signal file) produces the figure below.
signalx = randn(2e4,1);
signaly = randn(2e4,1);
window = length(signalx)/3;
noverlap = round(0.9*window);
fs = 2074;
[Pxy,F] = cpsd(signalx,signaly,window,noverlap,[],fs);
plot(F./1000,10.*log10(real(Pxy)))
hold on
cpsd(signalx,signaly,window,noverlap,[],fs);
legend(‘CPSD output’,’CPSD direct plot’)
I’m trying to run cpsd column-wise on a pair of very large matrices. Obviously I can’t just plot them one by one, but I don’t know how to interpret this difference and I’m not sure if I trust the output argument. Does anyone know what’s going on here? Thanks! When using cpsd to calculate the cross power spectral density, I’ve noticed that the plot produced by directly running the command with no output arguments is slightly different from what I get when I run it with an output argument and plot that output myself.
The following code (attached along with example signal file) produces the figure below.
signalx = randn(2e4,1);
signaly = randn(2e4,1);
window = length(signalx)/3;
noverlap = round(0.9*window);
fs = 2074;
[Pxy,F] = cpsd(signalx,signaly,window,noverlap,[],fs);
plot(F./1000,10.*log10(real(Pxy)))
hold on
cpsd(signalx,signaly,window,noverlap,[],fs);
legend(‘CPSD output’,’CPSD direct plot’)
I’m trying to run cpsd column-wise on a pair of very large matrices. Obviously I can’t just plot them one by one, but I don’t know how to interpret this difference and I’m not sure if I trust the output argument. Does anyone know what’s going on here? Thanks! signal processing, cross power spectral density, cpsd, spectral analysis MATLAB Answers — New Questions
How can I simulate this paper?
I need help to simulate this paper for my final project.
Please help me to simulate this paper.
thanksI need help to simulate this paper for my final project.
Please help me to simulate this paper.
thanks I need help to simulate this paper for my final project.
Please help me to simulate this paper.
thanks comparison of artifact correction methods for infant eeg applied to extraction of event-related potential signals MATLAB Answers — New Questions
Generating multiple page content using Report generator!
I am using report generator to generate a document in Matlab. The document is generated by form based generation process, where my template has a number of holes, at a well defined positions. I do not have any sections or chapter or paragraphs to append directly into.
The problem is in using the template and to genearate different pages. I tried using pageBreak() statement at the end of the page. And that being the last hole in the report. I receive the following error ”Error using mlreportgen.dom.Document/append Unable to append to #end# hole”. I did try adding additional hole in the template after the line of page break, buit still it loads my first holes content and then throws the same error.
To be more concise, I simply want to reuse the template(consititng of signle page with multiple holes) and loop it several times for the different data, so that I can capture all the single page document outputs in one single document.
Note: Above picture illustrates how the page generating function (defined by ‘MesaPointAnalys’) terminates.
Note: Above picture illustrates how the loop is performed to call for assignement for different page. The MesaPointAnalys is a page generating function and handles different data based on the page numbers.I am using report generator to generate a document in Matlab. The document is generated by form based generation process, where my template has a number of holes, at a well defined positions. I do not have any sections or chapter or paragraphs to append directly into.
The problem is in using the template and to genearate different pages. I tried using pageBreak() statement at the end of the page. And that being the last hole in the report. I receive the following error ”Error using mlreportgen.dom.Document/append Unable to append to #end# hole”. I did try adding additional hole in the template after the line of page break, buit still it loads my first holes content and then throws the same error.
To be more concise, I simply want to reuse the template(consititng of signle page with multiple holes) and loop it several times for the different data, so that I can capture all the single page document outputs in one single document.
Note: Above picture illustrates how the page generating function (defined by ‘MesaPointAnalys’) terminates.
Note: Above picture illustrates how the loop is performed to call for assignement for different page. The MesaPointAnalys is a page generating function and handles different data based on the page numbers. I am using report generator to generate a document in Matlab. The document is generated by form based generation process, where my template has a number of holes, at a well defined positions. I do not have any sections or chapter or paragraphs to append directly into.
The problem is in using the template and to genearate different pages. I tried using pageBreak() statement at the end of the page. And that being the last hole in the report. I receive the following error ”Error using mlreportgen.dom.Document/append Unable to append to #end# hole”. I did try adding additional hole in the template after the line of page break, buit still it loads my first holes content and then throws the same error.
To be more concise, I simply want to reuse the template(consititng of signle page with multiple holes) and loop it several times for the different data, so that I can capture all the single page document outputs in one single document.
Note: Above picture illustrates how the page generating function (defined by ‘MesaPointAnalys’) terminates.
Note: Above picture illustrates how the loop is performed to call for assignement for different page. The MesaPointAnalys is a page generating function and handles different data based on the page numbers. report generator MATLAB Answers — New Questions
Bayes Factor functions/packages
I am using the following two-sample tests for non-normal distributions:
chi2gof
kstest2
ranksum
kruskalwallis
and I would like to calculate the Bayes Factor as well.
I found the bayesFactor Version 1.0.0 (253 KB) by Bart Krekelberg. However, to the best of my understanfding, that package has a limited number of implemented tests:
One sample t-test (bf.ttest)
Two sample t-test (bf.ttest2)
N-Way Anova with fixed and random effects, including continuous co-variates (bf.anova)
Regression (bf.regression)
Pearson Correlation (bf.corr)
Binomial Test (bf.binom)
Experimental Design & Power Analysis (bf.designAnalysis)
and I am not sure if they can be used as additional analysis to the 4 initially listed ones that I am employing.
Does anyone know if there are other Matlab functions/packages to calculate the Bayes factor, in relation to the two-sample tests I am currently using (i.e. the chi2gof, the kstest2, the ranksum, and the kruskalwallis)?I am using the following two-sample tests for non-normal distributions:
chi2gof
kstest2
ranksum
kruskalwallis
and I would like to calculate the Bayes Factor as well.
I found the bayesFactor Version 1.0.0 (253 KB) by Bart Krekelberg. However, to the best of my understanfding, that package has a limited number of implemented tests:
One sample t-test (bf.ttest)
Two sample t-test (bf.ttest2)
N-Way Anova with fixed and random effects, including continuous co-variates (bf.anova)
Regression (bf.regression)
Pearson Correlation (bf.corr)
Binomial Test (bf.binom)
Experimental Design & Power Analysis (bf.designAnalysis)
and I am not sure if they can be used as additional analysis to the 4 initially listed ones that I am employing.
Does anyone know if there are other Matlab functions/packages to calculate the Bayes factor, in relation to the two-sample tests I am currently using (i.e. the chi2gof, the kstest2, the ranksum, and the kruskalwallis)? I am using the following two-sample tests for non-normal distributions:
chi2gof
kstest2
ranksum
kruskalwallis
and I would like to calculate the Bayes Factor as well.
I found the bayesFactor Version 1.0.0 (253 KB) by Bart Krekelberg. However, to the best of my understanfding, that package has a limited number of implemented tests:
One sample t-test (bf.ttest)
Two sample t-test (bf.ttest2)
N-Way Anova with fixed and random effects, including continuous co-variates (bf.anova)
Regression (bf.regression)
Pearson Correlation (bf.corr)
Binomial Test (bf.binom)
Experimental Design & Power Analysis (bf.designAnalysis)
and I am not sure if they can be used as additional analysis to the 4 initially listed ones that I am employing.
Does anyone know if there are other Matlab functions/packages to calculate the Bayes factor, in relation to the two-sample tests I am currently using (i.e. the chi2gof, the kstest2, the ranksum, and the kruskalwallis)? chi2gof, chi-square, kstest2, kolmogorov-smirnov test, ranksum, wilcoxon rank sum test, kruskalwallis, kruskal-wallis test, bayes factor MATLAB Answers — New Questions
Bar plot with a hatched fill pattern
I have a grouped bar plot, bb:
bb = bar(ax, x, y)
where ‘ax’ is the axis handle, x is a 1×7 datetime vector and y is a 5×7 double vector. For each of the seven dates, I get five bars with data.
I then specify the color of the bars:
for i = 1:5
bb(i).FaceColor = colmapLight(i,:);
bb(i).EdgeColor = colmapDark(i,:);
end
In addition to specifying the colors, I want to use a hatched fill pattern, e.g. horizontal lines in the first two bars in each group, and dots in the last three. I tried using the functions mentioned in this post (https://blogs.mathworks.com/pick/2011/07/15/creating-hatched-patches/), but I haven’t managed to make any of them work. I think the hatchfill function (https://se.mathworks.com/matlabcentral/fileexchange/30733-hatchfill) suits my needs best (I want to keep my custom bar colors; plus I don’t need a bitmap copy of the figure, want to keep it as a fig). However, the function works on ‘patch’ objects and I don’t know how to get their handles. The following:
hPatch = findobj(bb, ‘Type’, ‘patch’);
returns an empty, 0x0 GraphicsPlaceholder.
Does anyone know a way to solve this? Thanks in advance!I have a grouped bar plot, bb:
bb = bar(ax, x, y)
where ‘ax’ is the axis handle, x is a 1×7 datetime vector and y is a 5×7 double vector. For each of the seven dates, I get five bars with data.
I then specify the color of the bars:
for i = 1:5
bb(i).FaceColor = colmapLight(i,:);
bb(i).EdgeColor = colmapDark(i,:);
end
In addition to specifying the colors, I want to use a hatched fill pattern, e.g. horizontal lines in the first two bars in each group, and dots in the last three. I tried using the functions mentioned in this post (https://blogs.mathworks.com/pick/2011/07/15/creating-hatched-patches/), but I haven’t managed to make any of them work. I think the hatchfill function (https://se.mathworks.com/matlabcentral/fileexchange/30733-hatchfill) suits my needs best (I want to keep my custom bar colors; plus I don’t need a bitmap copy of the figure, want to keep it as a fig). However, the function works on ‘patch’ objects and I don’t know how to get their handles. The following:
hPatch = findobj(bb, ‘Type’, ‘patch’);
returns an empty, 0x0 GraphicsPlaceholder.
Does anyone know a way to solve this? Thanks in advance! I have a grouped bar plot, bb:
bb = bar(ax, x, y)
where ‘ax’ is the axis handle, x is a 1×7 datetime vector and y is a 5×7 double vector. For each of the seven dates, I get five bars with data.
I then specify the color of the bars:
for i = 1:5
bb(i).FaceColor = colmapLight(i,:);
bb(i).EdgeColor = colmapDark(i,:);
end
In addition to specifying the colors, I want to use a hatched fill pattern, e.g. horizontal lines in the first two bars in each group, and dots in the last three. I tried using the functions mentioned in this post (https://blogs.mathworks.com/pick/2011/07/15/creating-hatched-patches/), but I haven’t managed to make any of them work. I think the hatchfill function (https://se.mathworks.com/matlabcentral/fileexchange/30733-hatchfill) suits my needs best (I want to keep my custom bar colors; plus I don’t need a bitmap copy of the figure, want to keep it as a fig). However, the function works on ‘patch’ objects and I don’t know how to get their handles. The following:
hPatch = findobj(bb, ‘Type’, ‘patch’);
returns an empty, 0x0 GraphicsPlaceholder.
Does anyone know a way to solve this? Thanks in advance! bar, plot, patch, hatched, pattern MATLAB Answers — New Questions
cnn-lstm error
hello everyone
i have error whene i use cnn-lstm
this is the error
Error using trainNetwork (line 191)
Invalid training data. The output size (1024) of the last layer does not match the response size (1).
Error in Main_fn (line 266)
[trainedNet,traininfo] = trainNetwork(XTrain,YTrain,layers,options);
Error in Fig12_generator (line 49)
[Rate_DL,Rate_OPT]=Main_fn(L,My_ar,Mz_ar,M_bar,K_DL,Pt,kbeams(rr),Training_Size);
but whene use cnn onle the code run without error and i make every possible to fix it but it not work and i change the shape of YTrain but still the error
function [Rate_DL,Rate_OPT]=Main_fn(L,My,Mz,M_bar,K_DL,Pt,kbeams,Training_Size)
%% Description:
%
% This is the function called by the main script for ploting Figure 10
% in the original article mentioned below.
%
% version 1.0 (Last edited: 2019-05-10)
%
% The definitions and equations used in this code refer (mostly) to the
% following publication:
%
% Abdelrahman Taha, Muhammad Alrabeiah, and Ahmed Alkhateeb, "Enabling
% Large Intelligent Surfaces with Compressive Sensing and Deep Learning,"
% arXiv e-prints, p. arXiv:1904.10136, Apr 2019.
% [Online]. Available: https://arxiv.org/abs/1904.10136
%
% The DeepMIMO dataset is adopted.
% [Online]. Available: http://deepmimo.net/
%
% License: This code is licensed under a Creative Commons
% Attribution-NonCommercial-ShareAlike 4.0 International License.
% [Online]. Available: https://creativecommons.org/licenses/by-nc-sa/4.0/
% If you in any way use this code for research that results in
% publications, please cite our original article mentioned above.
%% System Model Parameters
params.scenario=’O1_28′; % DeepMIMO Dataset scenario: http://deepmimo.net/
params.active_BS=3; % active basestation(/s) in the chosen scenario
D_Lambda = 0.5; % Antenna spacing relative to the wavelength
BW = 100e6; % Bandwidth
Ut_row = 850; % user Ut row number
Ut_element = 90; % user Ut position from the row chosen above
Ur_rows = [1000 1200]; % user Ur rows
Validation_Size = 6200; % Validation dataset Size
K = 512; % number of subcarriers
miniBatchSize = 500; % Size of the minibatch for the Deep Learning
% Note: The axes of the antennas match the axes of the ray-tracing scenario
Mx = 1; % number of LIS reflecting elements across the x axis
M = Mx.*My.*Mz; % Total number of LIS reflecting elements
% Preallocation of output variables
Rate_DL = zeros(1,length(Training_Size));
Rate_OPT = Rate_DL;
LastValidationRMSE = Rate_DL;
%— Accounting SNR in ach rate calculations
%— Definning Noisy channel measurements
Gt=3; % dBi
Gr=3; % dBi
NF=5; % Noise figure at the User equipment
Process_Gain=10; % Channel estimation processing gain
noise_power_dB=-204+10*log10(BW/K)+NF-Process_Gain; % Noise power in dB
SNR=10^(.1*(-noise_power_dB))*(10^(.1*(Gt+Gr+Pt)))^2; % Signal-to-noise ratio
% channel estimation noise
noise_power_bar=10^(.1*(noise_power_dB))/(10^(.1*(Gt+Gr+Pt)));
No_user_pairs = (Ur_rows(2)-Ur_rows(1))*181; % Number of (Ut,Ur) user pairs
RandP_all = randperm(No_user_pairs).’; % Random permutation of the available dataset
%% Starting the code
disp(‘======================================================================================================================’);
disp([‘ Calculating for M = ‘ num2str(M)]);
Rand_M_bar_all = randperm(M);
%% Beamforming Codebook
% BF codebook parameters
over_sampling_x=1; % The beamsteering oversampling factor in the x direction
over_sampling_y=1; % The beamsteering oversampling factor in the y direction
over_sampling_z=1; % The beamsteering oversampling factor in the z direction
% Generating the BF codebook
[BF_codebook]=sqrt(Mx*My*Mz)*UPA_codebook_generator(Mx,My,Mz,over_sampling_x,over_sampling_y,over_sampling_z,D_Lambda);
codebook_size=size(BF_codebook,2);
%% DeepMIMO Dataset Generation
disp(‘————————————————————-‘);
disp([‘ Calculating for K_DL = ‘ num2str(K_DL)]);
% —— Inputs to the DeepMIMO dataset generation code ———— %
% Note: The axes of the antennas match the axes of the ray-tracing scenario
params.num_ant_x= Mx; % Number of the UPA antenna array on the x-axis
params.num_ant_y= My; % Number of the UPA antenna array on the y-axis
params.num_ant_z= Mz; % Number of the UPA antenna array on the z-axis
params.ant_spacing=D_Lambda; % ratio of the wavelnegth; for half wavelength enter .5
params.bandwidth= BW*1e-9; % The bandiwdth in GHz
params.num_OFDM= K; % Number of OFDM subcarriers
params.OFDM_sampling_factor=1; % The constructed channels will be calculated only at the sampled subcarriers (to reduce the size of the dataset)
params.OFDM_limit=K_DL*1; % Only the first params.OFDM_limit subcarriers will be considered when constructing the channels
params.num_paths=L; % Maximum number of paths to be considered (a value between 1 and 25), e.g., choose 1 if you are only interested in the strongest path
params.saveDataset=0;
disp([‘ Calculating for L = ‘ num2str(params.num_paths)]);
% —————— DeepMIMO "Ut" Dataset Generation —————–%
params.active_user_first=Ut_row;
params.active_user_last=Ut_row;
DeepMIMO_dataset=DeepMIMO_generator(params);
Ht = single(DeepMIMO_dataset{1}.user{Ut_element}.channel);
clear DeepMIMO_dataset
% —————— DeepMIMO "Ur" Dataset Generation —————–%
%Validation part for the actual achievable rate perf eval
Validation_Ind = RandP_all(end-Validation_Size+1:end);
[~,VI_sortind] = sort(Validation_Ind);
[~,VI_rev_sortind] = sort(VI_sortind);
%initialization
Ur_rows_step = 100; % access the dataset 100 rows at a time
Ur_rows_grid=Ur_rows(1):Ur_rows_step:Ur_rows(2);
Delta_H_max = single(0);
for pp = 1:1:numel(Ur_rows_grid)-1 % loop for Normalizing H
clear DeepMIMO_dataset
params.active_user_first=Ur_rows_grid(pp);
params.active_user_last=Ur_rows_grid(pp+1)-1;
[DeepMIMO_dataset,params]=DeepMIMO_generator(params);
for u=1:params.num_user
Hr = single(conj(DeepMIMO_dataset{1}.user{u}.channel));
Delta_H = max(max(abs(Ht.*Hr)));
if Delta_H >= Delta_H_max
Delta_H_max = single(Delta_H);
end
end
end
clear Delta_H
disp(‘=============================================================’);
disp([‘ Calculating for M_bar = ‘ num2str(M_bar)]);
Rand_M_bar =unique(Rand_M_bar_all(1:M_bar));
Ht_bar = reshape(Ht(Rand_M_bar,:),M_bar*K_DL,1);
DL_input = single(zeros(M_bar*K_DL*2,No_user_pairs));
DL_output = single(zeros(No_user_pairs,codebook_size));
DL_output_un= single(zeros(numel(Validation_Ind),codebook_size));
Delta_H_bar_max = single(0);
count=0;
for pp = 1:1:numel(Ur_rows_grid)-1
clear DeepMIMO_dataset
disp([‘Starting received user access ‘ num2str(pp)]);
params.active_user_first=Ur_rows_grid(pp);
params.active_user_last=Ur_rows_grid(pp+1)-1;
[DeepMIMO_dataset,params]=DeepMIMO_generator(params);
%% Construct Deep Learning inputs
u_step=100;
Htx=repmat(Ht(:,1),1,u_step);
Hrx=zeros(M,u_step);
for u=1:u_step:params.num_user
for uu=1:1:u_step
Hr = single(conj(DeepMIMO_dataset{1}.user{u+uu-1}.channel));
Hr_bar = reshape(Hr(Rand_M_bar,:),M_bar*K_DL,1);
%— Constructing the sampled channel
n1=sqrt(noise_power_bar/2)*(randn(M_bar*K_DL,1)+1j*randn(M_bar*K_DL,1));
n2=sqrt(noise_power_bar/2)*(randn(M_bar*K_DL,1)+1j*randn(M_bar*K_DL,1));
H_bar = ((Ht_bar+n1).*(Hr_bar+n2));
DL_input(:,u+uu-1+((pp-1)*params.num_user))= reshape([real(H_bar) imag(H_bar)].’,[],1);
Delta_H_bar = max(max(abs(H_bar)));
if Delta_H_bar >= Delta_H_bar_max
Delta_H_bar_max = single(Delta_H_bar);
end
Hrx(:,uu)=Hr(:,1);
end
%— Actual achievable rate for performance evaluation
H = Htx.*Hrx;
H_BF=H.’*BF_codebook;
SNR_sqrt_var = abs(H_BF);
for uu=1:1:u_step
if sum((Validation_Ind == u+uu-1+((pp-1)*params.num_user)))
count=count+1;
DL_output_un(count,:) = single(sum(log2(1+(SNR*((SNR_sqrt_var(uu,:)).^2))),1));
end
end
%— Label for the sampled channel
R = single(log2(1+(SNR_sqrt_var/Delta_H_max).^2));
% — DL output normalization
Delta_Out_max = max(R,[],2);
if ~sum(Delta_Out_max == 0)
Rn=diag(1./Delta_Out_max)*R;
end
DL_output(u+((pp-1)*params.num_user):u+((pp-1)*params.num_user)+u_step-1,:) = 1*Rn; %%%%% Normalized %%%%%
end
end
clear u Delta_H_bar R Rn
%– Sorting back the DL_output_un
DL_output_un = DL_output_un(VI_rev_sortind,:);
%— DL input normalization
DL_input= 1*(DL_input/Delta_H_bar_max); %%%%% Normalized from -1->1 %%%%%
%% DL Beamforming
% —————— Training and Testing Datasets —————–%
% Reshape for CNN-LSTM
% Assuming each sample is a sequence of features where each feature vector should be treated as a 1D image (sequence length x 1 x 1)
DL_output_reshaped = reshape(DL_output.’, size(DL_output,2), 1, 1, size(DL_output,1));
DL_output_reshaped_un = reshape(DL_output_un.’, size(DL_output_un,2), 1, 1, size(DL_output_un,1));
DL_input_reshaped = reshape(DL_input, size(DL_input,1), 1, 1, size(DL_input,2));
for dd=1:numel(Training_Size)
disp([‘ Calculating for Dataset Size = ‘ num2str(Training_Size(dd))]);
Training_Ind = RandP_all(1:Training_Size(dd));
% Index the reshaped data for training and validation
XTrain = single(DL_input_reshaped(:,1,:,Training_Ind));
YTrain = single(DL_output_reshaped(:,:,1,Training_Ind));
XValidation = single(DL_input_reshaped(:,1,:,Validation_Ind));
YValidation = single(DL_output_reshaped(:,:,1,Validation_Ind));
YValidation_un = single(DL_output_reshaped_un(:,:,1,:));
%% DL Model definition with adjusted pooling and convolution layers
layers = [
imageInputLayer([size(XTrain,1), 1, 1],’Name’,’input’,’Normalization’,’none’)
convolution2dLayer(3, 64, ‘Padding’, ‘same’, ‘Name’, ‘conv1’)
batchNormalizationLayer(‘Name’, ‘bn1’)
reluLayer(‘Name’, ‘relu1’)
maxPooling2dLayer([3,1], ‘Stride’, [3,1], ‘Name’, ‘maxpool1’)
convolution2dLayer(3, 128, ‘Padding’, ‘same’, ‘Name’, ‘conv2’)
batchNormalizationLayer(‘Name’, ‘bn2’)
reluLayer(‘Name’, ‘relu2’)
maxPooling2dLayer([3,1], ‘Stride’, [3,1], ‘Name’, ‘maxpool2’)
convolution2dLayer(3, 256, ‘Padding’, ‘same’, ‘Name’, ‘conv3’)
batchNormalizationLayer(‘Name’, ‘bn3’)
reluLayer(‘Name’, ‘relu3’)
maxPooling2dLayer([3,1], ‘Stride’, [3,1], ‘Name’, ‘maxpool3’)
flattenLayer(‘Name’, ‘flatten’)
lstmLayer(128, ‘Name’, ‘lstm1’, ‘OutputMode’, ‘sequence’)
lstmLayer(128, ‘Name’, ‘lstm2’, ‘OutputMode’, ‘last’)
fullyConnectedLayer(512, ‘Name’, ‘fc1’)
reluLayer(‘Name’, ‘relu4’)
dropoutLayer(0.5, ‘Name’, ‘dropout1’)
fullyConnectedLayer(1024, ‘Name’, ‘fc2’)
reluLayer(‘Name’, ‘relu5’)
dropoutLayer(0.5, ‘Name’, ‘dropout2’)
fullyConnectedLayer(2048, ‘Name’, ‘fc3’)
reluLayer(‘Name’, ‘relu6’)
dropoutLayer(0.5, ‘Name’, ‘dropout3’)
fullyConnectedLayer(size(YTrain,3), ‘Name’, ‘fc4’)
regressionLayer(‘Name’, ‘output’)
];
options = trainingOptions(‘rmsprop’, …
‘MiniBatchSize’, miniBatchSize, …
‘MaxEpochs’, 20, …
‘InitialLearnRate’, 1e-3, …
‘LearnRateSchedule’, ‘piecewise’, …
‘LearnRateDropFactor’, 0.5, …
‘LearnRateDropPeriod’, 10, …
‘L2Regularization’, 1e-4, …
‘Shuffle’, ‘every-epoch’, …
‘ValidationData’, {XValidation, YValidation}, …
‘ValidationFrequency’, 30, …
‘Verbose’, 1, …
‘Plots’, ‘none’, …
‘ExecutionEnvironment’, ‘cpu’);
[~,Indmax_OPT]= max(YValidation,[],3);
Indmax_OPT = squeeze(Indmax_OPT); %Upper bound on achievable rates
MaxR_OPT = single(zeros(numel(Indmax_OPT),1));
[trainedNet,traininfo] = trainNetwork(XTrain,YTrain,layers,options);
YPredicted = predict(trainedNet,XValidation);
% ——————— Achievable Rate ————————–%
[~,Indmax_DL] = maxk(YPredicted,kbeams,2);
MaxR_DL = single(zeros(size(Indmax_DL,1),1)); %True achievable rates
for b=1:size(Indmax_DL,1)
MaxR_DL(b) = max(squeeze(YValidation_un(1,1,Indmax_DL(b,:),b)));
MaxR_OPT(b) = squeeze(YValidation_un(1,1,Indmax_OPT(b),b));
end
Rate_OPT(dd) = mean(MaxR_OPT);
Rate_DL(dd) = mean(MaxR_DL);
LastValidationRMSE(dd) = traininfo.ValidationRMSE(end);
clear trainedNet traininfo YPredicted
clear layers options Rate_DL_Temp MaxR_DL_Temp Highest_Rate
end
endhello everyone
i have error whene i use cnn-lstm
this is the error
Error using trainNetwork (line 191)
Invalid training data. The output size (1024) of the last layer does not match the response size (1).
Error in Main_fn (line 266)
[trainedNet,traininfo] = trainNetwork(XTrain,YTrain,layers,options);
Error in Fig12_generator (line 49)
[Rate_DL,Rate_OPT]=Main_fn(L,My_ar,Mz_ar,M_bar,K_DL,Pt,kbeams(rr),Training_Size);
but whene use cnn onle the code run without error and i make every possible to fix it but it not work and i change the shape of YTrain but still the error
function [Rate_DL,Rate_OPT]=Main_fn(L,My,Mz,M_bar,K_DL,Pt,kbeams,Training_Size)
%% Description:
%
% This is the function called by the main script for ploting Figure 10
% in the original article mentioned below.
%
% version 1.0 (Last edited: 2019-05-10)
%
% The definitions and equations used in this code refer (mostly) to the
% following publication:
%
% Abdelrahman Taha, Muhammad Alrabeiah, and Ahmed Alkhateeb, "Enabling
% Large Intelligent Surfaces with Compressive Sensing and Deep Learning,"
% arXiv e-prints, p. arXiv:1904.10136, Apr 2019.
% [Online]. Available: https://arxiv.org/abs/1904.10136
%
% The DeepMIMO dataset is adopted.
% [Online]. Available: http://deepmimo.net/
%
% License: This code is licensed under a Creative Commons
% Attribution-NonCommercial-ShareAlike 4.0 International License.
% [Online]. Available: https://creativecommons.org/licenses/by-nc-sa/4.0/
% If you in any way use this code for research that results in
% publications, please cite our original article mentioned above.
%% System Model Parameters
params.scenario=’O1_28′; % DeepMIMO Dataset scenario: http://deepmimo.net/
params.active_BS=3; % active basestation(/s) in the chosen scenario
D_Lambda = 0.5; % Antenna spacing relative to the wavelength
BW = 100e6; % Bandwidth
Ut_row = 850; % user Ut row number
Ut_element = 90; % user Ut position from the row chosen above
Ur_rows = [1000 1200]; % user Ur rows
Validation_Size = 6200; % Validation dataset Size
K = 512; % number of subcarriers
miniBatchSize = 500; % Size of the minibatch for the Deep Learning
% Note: The axes of the antennas match the axes of the ray-tracing scenario
Mx = 1; % number of LIS reflecting elements across the x axis
M = Mx.*My.*Mz; % Total number of LIS reflecting elements
% Preallocation of output variables
Rate_DL = zeros(1,length(Training_Size));
Rate_OPT = Rate_DL;
LastValidationRMSE = Rate_DL;
%— Accounting SNR in ach rate calculations
%— Definning Noisy channel measurements
Gt=3; % dBi
Gr=3; % dBi
NF=5; % Noise figure at the User equipment
Process_Gain=10; % Channel estimation processing gain
noise_power_dB=-204+10*log10(BW/K)+NF-Process_Gain; % Noise power in dB
SNR=10^(.1*(-noise_power_dB))*(10^(.1*(Gt+Gr+Pt)))^2; % Signal-to-noise ratio
% channel estimation noise
noise_power_bar=10^(.1*(noise_power_dB))/(10^(.1*(Gt+Gr+Pt)));
No_user_pairs = (Ur_rows(2)-Ur_rows(1))*181; % Number of (Ut,Ur) user pairs
RandP_all = randperm(No_user_pairs).’; % Random permutation of the available dataset
%% Starting the code
disp(‘======================================================================================================================’);
disp([‘ Calculating for M = ‘ num2str(M)]);
Rand_M_bar_all = randperm(M);
%% Beamforming Codebook
% BF codebook parameters
over_sampling_x=1; % The beamsteering oversampling factor in the x direction
over_sampling_y=1; % The beamsteering oversampling factor in the y direction
over_sampling_z=1; % The beamsteering oversampling factor in the z direction
% Generating the BF codebook
[BF_codebook]=sqrt(Mx*My*Mz)*UPA_codebook_generator(Mx,My,Mz,over_sampling_x,over_sampling_y,over_sampling_z,D_Lambda);
codebook_size=size(BF_codebook,2);
%% DeepMIMO Dataset Generation
disp(‘————————————————————-‘);
disp([‘ Calculating for K_DL = ‘ num2str(K_DL)]);
% —— Inputs to the DeepMIMO dataset generation code ———— %
% Note: The axes of the antennas match the axes of the ray-tracing scenario
params.num_ant_x= Mx; % Number of the UPA antenna array on the x-axis
params.num_ant_y= My; % Number of the UPA antenna array on the y-axis
params.num_ant_z= Mz; % Number of the UPA antenna array on the z-axis
params.ant_spacing=D_Lambda; % ratio of the wavelnegth; for half wavelength enter .5
params.bandwidth= BW*1e-9; % The bandiwdth in GHz
params.num_OFDM= K; % Number of OFDM subcarriers
params.OFDM_sampling_factor=1; % The constructed channels will be calculated only at the sampled subcarriers (to reduce the size of the dataset)
params.OFDM_limit=K_DL*1; % Only the first params.OFDM_limit subcarriers will be considered when constructing the channels
params.num_paths=L; % Maximum number of paths to be considered (a value between 1 and 25), e.g., choose 1 if you are only interested in the strongest path
params.saveDataset=0;
disp([‘ Calculating for L = ‘ num2str(params.num_paths)]);
% —————— DeepMIMO "Ut" Dataset Generation —————–%
params.active_user_first=Ut_row;
params.active_user_last=Ut_row;
DeepMIMO_dataset=DeepMIMO_generator(params);
Ht = single(DeepMIMO_dataset{1}.user{Ut_element}.channel);
clear DeepMIMO_dataset
% —————— DeepMIMO "Ur" Dataset Generation —————–%
%Validation part for the actual achievable rate perf eval
Validation_Ind = RandP_all(end-Validation_Size+1:end);
[~,VI_sortind] = sort(Validation_Ind);
[~,VI_rev_sortind] = sort(VI_sortind);
%initialization
Ur_rows_step = 100; % access the dataset 100 rows at a time
Ur_rows_grid=Ur_rows(1):Ur_rows_step:Ur_rows(2);
Delta_H_max = single(0);
for pp = 1:1:numel(Ur_rows_grid)-1 % loop for Normalizing H
clear DeepMIMO_dataset
params.active_user_first=Ur_rows_grid(pp);
params.active_user_last=Ur_rows_grid(pp+1)-1;
[DeepMIMO_dataset,params]=DeepMIMO_generator(params);
for u=1:params.num_user
Hr = single(conj(DeepMIMO_dataset{1}.user{u}.channel));
Delta_H = max(max(abs(Ht.*Hr)));
if Delta_H >= Delta_H_max
Delta_H_max = single(Delta_H);
end
end
end
clear Delta_H
disp(‘=============================================================’);
disp([‘ Calculating for M_bar = ‘ num2str(M_bar)]);
Rand_M_bar =unique(Rand_M_bar_all(1:M_bar));
Ht_bar = reshape(Ht(Rand_M_bar,:),M_bar*K_DL,1);
DL_input = single(zeros(M_bar*K_DL*2,No_user_pairs));
DL_output = single(zeros(No_user_pairs,codebook_size));
DL_output_un= single(zeros(numel(Validation_Ind),codebook_size));
Delta_H_bar_max = single(0);
count=0;
for pp = 1:1:numel(Ur_rows_grid)-1
clear DeepMIMO_dataset
disp([‘Starting received user access ‘ num2str(pp)]);
params.active_user_first=Ur_rows_grid(pp);
params.active_user_last=Ur_rows_grid(pp+1)-1;
[DeepMIMO_dataset,params]=DeepMIMO_generator(params);
%% Construct Deep Learning inputs
u_step=100;
Htx=repmat(Ht(:,1),1,u_step);
Hrx=zeros(M,u_step);
for u=1:u_step:params.num_user
for uu=1:1:u_step
Hr = single(conj(DeepMIMO_dataset{1}.user{u+uu-1}.channel));
Hr_bar = reshape(Hr(Rand_M_bar,:),M_bar*K_DL,1);
%— Constructing the sampled channel
n1=sqrt(noise_power_bar/2)*(randn(M_bar*K_DL,1)+1j*randn(M_bar*K_DL,1));
n2=sqrt(noise_power_bar/2)*(randn(M_bar*K_DL,1)+1j*randn(M_bar*K_DL,1));
H_bar = ((Ht_bar+n1).*(Hr_bar+n2));
DL_input(:,u+uu-1+((pp-1)*params.num_user))= reshape([real(H_bar) imag(H_bar)].’,[],1);
Delta_H_bar = max(max(abs(H_bar)));
if Delta_H_bar >= Delta_H_bar_max
Delta_H_bar_max = single(Delta_H_bar);
end
Hrx(:,uu)=Hr(:,1);
end
%— Actual achievable rate for performance evaluation
H = Htx.*Hrx;
H_BF=H.’*BF_codebook;
SNR_sqrt_var = abs(H_BF);
for uu=1:1:u_step
if sum((Validation_Ind == u+uu-1+((pp-1)*params.num_user)))
count=count+1;
DL_output_un(count,:) = single(sum(log2(1+(SNR*((SNR_sqrt_var(uu,:)).^2))),1));
end
end
%— Label for the sampled channel
R = single(log2(1+(SNR_sqrt_var/Delta_H_max).^2));
% — DL output normalization
Delta_Out_max = max(R,[],2);
if ~sum(Delta_Out_max == 0)
Rn=diag(1./Delta_Out_max)*R;
end
DL_output(u+((pp-1)*params.num_user):u+((pp-1)*params.num_user)+u_step-1,:) = 1*Rn; %%%%% Normalized %%%%%
end
end
clear u Delta_H_bar R Rn
%– Sorting back the DL_output_un
DL_output_un = DL_output_un(VI_rev_sortind,:);
%— DL input normalization
DL_input= 1*(DL_input/Delta_H_bar_max); %%%%% Normalized from -1->1 %%%%%
%% DL Beamforming
% —————— Training and Testing Datasets —————–%
% Reshape for CNN-LSTM
% Assuming each sample is a sequence of features where each feature vector should be treated as a 1D image (sequence length x 1 x 1)
DL_output_reshaped = reshape(DL_output.’, size(DL_output,2), 1, 1, size(DL_output,1));
DL_output_reshaped_un = reshape(DL_output_un.’, size(DL_output_un,2), 1, 1, size(DL_output_un,1));
DL_input_reshaped = reshape(DL_input, size(DL_input,1), 1, 1, size(DL_input,2));
for dd=1:numel(Training_Size)
disp([‘ Calculating for Dataset Size = ‘ num2str(Training_Size(dd))]);
Training_Ind = RandP_all(1:Training_Size(dd));
% Index the reshaped data for training and validation
XTrain = single(DL_input_reshaped(:,1,:,Training_Ind));
YTrain = single(DL_output_reshaped(:,:,1,Training_Ind));
XValidation = single(DL_input_reshaped(:,1,:,Validation_Ind));
YValidation = single(DL_output_reshaped(:,:,1,Validation_Ind));
YValidation_un = single(DL_output_reshaped_un(:,:,1,:));
%% DL Model definition with adjusted pooling and convolution layers
layers = [
imageInputLayer([size(XTrain,1), 1, 1],’Name’,’input’,’Normalization’,’none’)
convolution2dLayer(3, 64, ‘Padding’, ‘same’, ‘Name’, ‘conv1’)
batchNormalizationLayer(‘Name’, ‘bn1’)
reluLayer(‘Name’, ‘relu1’)
maxPooling2dLayer([3,1], ‘Stride’, [3,1], ‘Name’, ‘maxpool1’)
convolution2dLayer(3, 128, ‘Padding’, ‘same’, ‘Name’, ‘conv2’)
batchNormalizationLayer(‘Name’, ‘bn2’)
reluLayer(‘Name’, ‘relu2’)
maxPooling2dLayer([3,1], ‘Stride’, [3,1], ‘Name’, ‘maxpool2’)
convolution2dLayer(3, 256, ‘Padding’, ‘same’, ‘Name’, ‘conv3’)
batchNormalizationLayer(‘Name’, ‘bn3’)
reluLayer(‘Name’, ‘relu3’)
maxPooling2dLayer([3,1], ‘Stride’, [3,1], ‘Name’, ‘maxpool3’)
flattenLayer(‘Name’, ‘flatten’)
lstmLayer(128, ‘Name’, ‘lstm1’, ‘OutputMode’, ‘sequence’)
lstmLayer(128, ‘Name’, ‘lstm2’, ‘OutputMode’, ‘last’)
fullyConnectedLayer(512, ‘Name’, ‘fc1’)
reluLayer(‘Name’, ‘relu4’)
dropoutLayer(0.5, ‘Name’, ‘dropout1’)
fullyConnectedLayer(1024, ‘Name’, ‘fc2’)
reluLayer(‘Name’, ‘relu5’)
dropoutLayer(0.5, ‘Name’, ‘dropout2’)
fullyConnectedLayer(2048, ‘Name’, ‘fc3’)
reluLayer(‘Name’, ‘relu6’)
dropoutLayer(0.5, ‘Name’, ‘dropout3’)
fullyConnectedLayer(size(YTrain,3), ‘Name’, ‘fc4’)
regressionLayer(‘Name’, ‘output’)
];
options = trainingOptions(‘rmsprop’, …
‘MiniBatchSize’, miniBatchSize, …
‘MaxEpochs’, 20, …
‘InitialLearnRate’, 1e-3, …
‘LearnRateSchedule’, ‘piecewise’, …
‘LearnRateDropFactor’, 0.5, …
‘LearnRateDropPeriod’, 10, …
‘L2Regularization’, 1e-4, …
‘Shuffle’, ‘every-epoch’, …
‘ValidationData’, {XValidation, YValidation}, …
‘ValidationFrequency’, 30, …
‘Verbose’, 1, …
‘Plots’, ‘none’, …
‘ExecutionEnvironment’, ‘cpu’);
[~,Indmax_OPT]= max(YValidation,[],3);
Indmax_OPT = squeeze(Indmax_OPT); %Upper bound on achievable rates
MaxR_OPT = single(zeros(numel(Indmax_OPT),1));
[trainedNet,traininfo] = trainNetwork(XTrain,YTrain,layers,options);
YPredicted = predict(trainedNet,XValidation);
% ——————— Achievable Rate ————————–%
[~,Indmax_DL] = maxk(YPredicted,kbeams,2);
MaxR_DL = single(zeros(size(Indmax_DL,1),1)); %True achievable rates
for b=1:size(Indmax_DL,1)
MaxR_DL(b) = max(squeeze(YValidation_un(1,1,Indmax_DL(b,:),b)));
MaxR_OPT(b) = squeeze(YValidation_un(1,1,Indmax_OPT(b),b));
end
Rate_OPT(dd) = mean(MaxR_OPT);
Rate_DL(dd) = mean(MaxR_DL);
LastValidationRMSE(dd) = traininfo.ValidationRMSE(end);
clear trainedNet traininfo YPredicted
clear layers options Rate_DL_Temp MaxR_DL_Temp Highest_Rate
end
end hello everyone
i have error whene i use cnn-lstm
this is the error
Error using trainNetwork (line 191)
Invalid training data. The output size (1024) of the last layer does not match the response size (1).
Error in Main_fn (line 266)
[trainedNet,traininfo] = trainNetwork(XTrain,YTrain,layers,options);
Error in Fig12_generator (line 49)
[Rate_DL,Rate_OPT]=Main_fn(L,My_ar,Mz_ar,M_bar,K_DL,Pt,kbeams(rr),Training_Size);
but whene use cnn onle the code run without error and i make every possible to fix it but it not work and i change the shape of YTrain but still the error
function [Rate_DL,Rate_OPT]=Main_fn(L,My,Mz,M_bar,K_DL,Pt,kbeams,Training_Size)
%% Description:
%
% This is the function called by the main script for ploting Figure 10
% in the original article mentioned below.
%
% version 1.0 (Last edited: 2019-05-10)
%
% The definitions and equations used in this code refer (mostly) to the
% following publication:
%
% Abdelrahman Taha, Muhammad Alrabeiah, and Ahmed Alkhateeb, "Enabling
% Large Intelligent Surfaces with Compressive Sensing and Deep Learning,"
% arXiv e-prints, p. arXiv:1904.10136, Apr 2019.
% [Online]. Available: https://arxiv.org/abs/1904.10136
%
% The DeepMIMO dataset is adopted.
% [Online]. Available: http://deepmimo.net/
%
% License: This code is licensed under a Creative Commons
% Attribution-NonCommercial-ShareAlike 4.0 International License.
% [Online]. Available: https://creativecommons.org/licenses/by-nc-sa/4.0/
% If you in any way use this code for research that results in
% publications, please cite our original article mentioned above.
%% System Model Parameters
params.scenario=’O1_28′; % DeepMIMO Dataset scenario: http://deepmimo.net/
params.active_BS=3; % active basestation(/s) in the chosen scenario
D_Lambda = 0.5; % Antenna spacing relative to the wavelength
BW = 100e6; % Bandwidth
Ut_row = 850; % user Ut row number
Ut_element = 90; % user Ut position from the row chosen above
Ur_rows = [1000 1200]; % user Ur rows
Validation_Size = 6200; % Validation dataset Size
K = 512; % number of subcarriers
miniBatchSize = 500; % Size of the minibatch for the Deep Learning
% Note: The axes of the antennas match the axes of the ray-tracing scenario
Mx = 1; % number of LIS reflecting elements across the x axis
M = Mx.*My.*Mz; % Total number of LIS reflecting elements
% Preallocation of output variables
Rate_DL = zeros(1,length(Training_Size));
Rate_OPT = Rate_DL;
LastValidationRMSE = Rate_DL;
%— Accounting SNR in ach rate calculations
%— Definning Noisy channel measurements
Gt=3; % dBi
Gr=3; % dBi
NF=5; % Noise figure at the User equipment
Process_Gain=10; % Channel estimation processing gain
noise_power_dB=-204+10*log10(BW/K)+NF-Process_Gain; % Noise power in dB
SNR=10^(.1*(-noise_power_dB))*(10^(.1*(Gt+Gr+Pt)))^2; % Signal-to-noise ratio
% channel estimation noise
noise_power_bar=10^(.1*(noise_power_dB))/(10^(.1*(Gt+Gr+Pt)));
No_user_pairs = (Ur_rows(2)-Ur_rows(1))*181; % Number of (Ut,Ur) user pairs
RandP_all = randperm(No_user_pairs).’; % Random permutation of the available dataset
%% Starting the code
disp(‘======================================================================================================================’);
disp([‘ Calculating for M = ‘ num2str(M)]);
Rand_M_bar_all = randperm(M);
%% Beamforming Codebook
% BF codebook parameters
over_sampling_x=1; % The beamsteering oversampling factor in the x direction
over_sampling_y=1; % The beamsteering oversampling factor in the y direction
over_sampling_z=1; % The beamsteering oversampling factor in the z direction
% Generating the BF codebook
[BF_codebook]=sqrt(Mx*My*Mz)*UPA_codebook_generator(Mx,My,Mz,over_sampling_x,over_sampling_y,over_sampling_z,D_Lambda);
codebook_size=size(BF_codebook,2);
%% DeepMIMO Dataset Generation
disp(‘————————————————————-‘);
disp([‘ Calculating for K_DL = ‘ num2str(K_DL)]);
% —— Inputs to the DeepMIMO dataset generation code ———— %
% Note: The axes of the antennas match the axes of the ray-tracing scenario
params.num_ant_x= Mx; % Number of the UPA antenna array on the x-axis
params.num_ant_y= My; % Number of the UPA antenna array on the y-axis
params.num_ant_z= Mz; % Number of the UPA antenna array on the z-axis
params.ant_spacing=D_Lambda; % ratio of the wavelnegth; for half wavelength enter .5
params.bandwidth= BW*1e-9; % The bandiwdth in GHz
params.num_OFDM= K; % Number of OFDM subcarriers
params.OFDM_sampling_factor=1; % The constructed channels will be calculated only at the sampled subcarriers (to reduce the size of the dataset)
params.OFDM_limit=K_DL*1; % Only the first params.OFDM_limit subcarriers will be considered when constructing the channels
params.num_paths=L; % Maximum number of paths to be considered (a value between 1 and 25), e.g., choose 1 if you are only interested in the strongest path
params.saveDataset=0;
disp([‘ Calculating for L = ‘ num2str(params.num_paths)]);
% —————— DeepMIMO "Ut" Dataset Generation —————–%
params.active_user_first=Ut_row;
params.active_user_last=Ut_row;
DeepMIMO_dataset=DeepMIMO_generator(params);
Ht = single(DeepMIMO_dataset{1}.user{Ut_element}.channel);
clear DeepMIMO_dataset
% —————— DeepMIMO "Ur" Dataset Generation —————–%
%Validation part for the actual achievable rate perf eval
Validation_Ind = RandP_all(end-Validation_Size+1:end);
[~,VI_sortind] = sort(Validation_Ind);
[~,VI_rev_sortind] = sort(VI_sortind);
%initialization
Ur_rows_step = 100; % access the dataset 100 rows at a time
Ur_rows_grid=Ur_rows(1):Ur_rows_step:Ur_rows(2);
Delta_H_max = single(0);
for pp = 1:1:numel(Ur_rows_grid)-1 % loop for Normalizing H
clear DeepMIMO_dataset
params.active_user_first=Ur_rows_grid(pp);
params.active_user_last=Ur_rows_grid(pp+1)-1;
[DeepMIMO_dataset,params]=DeepMIMO_generator(params);
for u=1:params.num_user
Hr = single(conj(DeepMIMO_dataset{1}.user{u}.channel));
Delta_H = max(max(abs(Ht.*Hr)));
if Delta_H >= Delta_H_max
Delta_H_max = single(Delta_H);
end
end
end
clear Delta_H
disp(‘=============================================================’);
disp([‘ Calculating for M_bar = ‘ num2str(M_bar)]);
Rand_M_bar =unique(Rand_M_bar_all(1:M_bar));
Ht_bar = reshape(Ht(Rand_M_bar,:),M_bar*K_DL,1);
DL_input = single(zeros(M_bar*K_DL*2,No_user_pairs));
DL_output = single(zeros(No_user_pairs,codebook_size));
DL_output_un= single(zeros(numel(Validation_Ind),codebook_size));
Delta_H_bar_max = single(0);
count=0;
for pp = 1:1:numel(Ur_rows_grid)-1
clear DeepMIMO_dataset
disp([‘Starting received user access ‘ num2str(pp)]);
params.active_user_first=Ur_rows_grid(pp);
params.active_user_last=Ur_rows_grid(pp+1)-1;
[DeepMIMO_dataset,params]=DeepMIMO_generator(params);
%% Construct Deep Learning inputs
u_step=100;
Htx=repmat(Ht(:,1),1,u_step);
Hrx=zeros(M,u_step);
for u=1:u_step:params.num_user
for uu=1:1:u_step
Hr = single(conj(DeepMIMO_dataset{1}.user{u+uu-1}.channel));
Hr_bar = reshape(Hr(Rand_M_bar,:),M_bar*K_DL,1);
%— Constructing the sampled channel
n1=sqrt(noise_power_bar/2)*(randn(M_bar*K_DL,1)+1j*randn(M_bar*K_DL,1));
n2=sqrt(noise_power_bar/2)*(randn(M_bar*K_DL,1)+1j*randn(M_bar*K_DL,1));
H_bar = ((Ht_bar+n1).*(Hr_bar+n2));
DL_input(:,u+uu-1+((pp-1)*params.num_user))= reshape([real(H_bar) imag(H_bar)].’,[],1);
Delta_H_bar = max(max(abs(H_bar)));
if Delta_H_bar >= Delta_H_bar_max
Delta_H_bar_max = single(Delta_H_bar);
end
Hrx(:,uu)=Hr(:,1);
end
%— Actual achievable rate for performance evaluation
H = Htx.*Hrx;
H_BF=H.’*BF_codebook;
SNR_sqrt_var = abs(H_BF);
for uu=1:1:u_step
if sum((Validation_Ind == u+uu-1+((pp-1)*params.num_user)))
count=count+1;
DL_output_un(count,:) = single(sum(log2(1+(SNR*((SNR_sqrt_var(uu,:)).^2))),1));
end
end
%— Label for the sampled channel
R = single(log2(1+(SNR_sqrt_var/Delta_H_max).^2));
% — DL output normalization
Delta_Out_max = max(R,[],2);
if ~sum(Delta_Out_max == 0)
Rn=diag(1./Delta_Out_max)*R;
end
DL_output(u+((pp-1)*params.num_user):u+((pp-1)*params.num_user)+u_step-1,:) = 1*Rn; %%%%% Normalized %%%%%
end
end
clear u Delta_H_bar R Rn
%– Sorting back the DL_output_un
DL_output_un = DL_output_un(VI_rev_sortind,:);
%— DL input normalization
DL_input= 1*(DL_input/Delta_H_bar_max); %%%%% Normalized from -1->1 %%%%%
%% DL Beamforming
% —————— Training and Testing Datasets —————–%
% Reshape for CNN-LSTM
% Assuming each sample is a sequence of features where each feature vector should be treated as a 1D image (sequence length x 1 x 1)
DL_output_reshaped = reshape(DL_output.’, size(DL_output,2), 1, 1, size(DL_output,1));
DL_output_reshaped_un = reshape(DL_output_un.’, size(DL_output_un,2), 1, 1, size(DL_output_un,1));
DL_input_reshaped = reshape(DL_input, size(DL_input,1), 1, 1, size(DL_input,2));
for dd=1:numel(Training_Size)
disp([‘ Calculating for Dataset Size = ‘ num2str(Training_Size(dd))]);
Training_Ind = RandP_all(1:Training_Size(dd));
% Index the reshaped data for training and validation
XTrain = single(DL_input_reshaped(:,1,:,Training_Ind));
YTrain = single(DL_output_reshaped(:,:,1,Training_Ind));
XValidation = single(DL_input_reshaped(:,1,:,Validation_Ind));
YValidation = single(DL_output_reshaped(:,:,1,Validation_Ind));
YValidation_un = single(DL_output_reshaped_un(:,:,1,:));
%% DL Model definition with adjusted pooling and convolution layers
layers = [
imageInputLayer([size(XTrain,1), 1, 1],’Name’,’input’,’Normalization’,’none’)
convolution2dLayer(3, 64, ‘Padding’, ‘same’, ‘Name’, ‘conv1’)
batchNormalizationLayer(‘Name’, ‘bn1’)
reluLayer(‘Name’, ‘relu1’)
maxPooling2dLayer([3,1], ‘Stride’, [3,1], ‘Name’, ‘maxpool1’)
convolution2dLayer(3, 128, ‘Padding’, ‘same’, ‘Name’, ‘conv2’)
batchNormalizationLayer(‘Name’, ‘bn2’)
reluLayer(‘Name’, ‘relu2’)
maxPooling2dLayer([3,1], ‘Stride’, [3,1], ‘Name’, ‘maxpool2’)
convolution2dLayer(3, 256, ‘Padding’, ‘same’, ‘Name’, ‘conv3’)
batchNormalizationLayer(‘Name’, ‘bn3’)
reluLayer(‘Name’, ‘relu3’)
maxPooling2dLayer([3,1], ‘Stride’, [3,1], ‘Name’, ‘maxpool3’)
flattenLayer(‘Name’, ‘flatten’)
lstmLayer(128, ‘Name’, ‘lstm1’, ‘OutputMode’, ‘sequence’)
lstmLayer(128, ‘Name’, ‘lstm2’, ‘OutputMode’, ‘last’)
fullyConnectedLayer(512, ‘Name’, ‘fc1’)
reluLayer(‘Name’, ‘relu4’)
dropoutLayer(0.5, ‘Name’, ‘dropout1’)
fullyConnectedLayer(1024, ‘Name’, ‘fc2’)
reluLayer(‘Name’, ‘relu5’)
dropoutLayer(0.5, ‘Name’, ‘dropout2’)
fullyConnectedLayer(2048, ‘Name’, ‘fc3’)
reluLayer(‘Name’, ‘relu6’)
dropoutLayer(0.5, ‘Name’, ‘dropout3’)
fullyConnectedLayer(size(YTrain,3), ‘Name’, ‘fc4’)
regressionLayer(‘Name’, ‘output’)
];
options = trainingOptions(‘rmsprop’, …
‘MiniBatchSize’, miniBatchSize, …
‘MaxEpochs’, 20, …
‘InitialLearnRate’, 1e-3, …
‘LearnRateSchedule’, ‘piecewise’, …
‘LearnRateDropFactor’, 0.5, …
‘LearnRateDropPeriod’, 10, …
‘L2Regularization’, 1e-4, …
‘Shuffle’, ‘every-epoch’, …
‘ValidationData’, {XValidation, YValidation}, …
‘ValidationFrequency’, 30, …
‘Verbose’, 1, …
‘Plots’, ‘none’, …
‘ExecutionEnvironment’, ‘cpu’);
[~,Indmax_OPT]= max(YValidation,[],3);
Indmax_OPT = squeeze(Indmax_OPT); %Upper bound on achievable rates
MaxR_OPT = single(zeros(numel(Indmax_OPT),1));
[trainedNet,traininfo] = trainNetwork(XTrain,YTrain,layers,options);
YPredicted = predict(trainedNet,XValidation);
% ——————— Achievable Rate ————————–%
[~,Indmax_DL] = maxk(YPredicted,kbeams,2);
MaxR_DL = single(zeros(size(Indmax_DL,1),1)); %True achievable rates
for b=1:size(Indmax_DL,1)
MaxR_DL(b) = max(squeeze(YValidation_un(1,1,Indmax_DL(b,:),b)));
MaxR_OPT(b) = squeeze(YValidation_un(1,1,Indmax_OPT(b),b));
end
Rate_OPT(dd) = mean(MaxR_OPT);
Rate_DL(dd) = mean(MaxR_DL);
LastValidationRMSE(dd) = traininfo.ValidationRMSE(end);
clear trainedNet traininfo YPredicted
clear layers options Rate_DL_Temp MaxR_DL_Temp Highest_Rate
end
end deep learning, cnn, communication MATLAB Answers — New Questions
Mean and Standard Deviation of outputs on a neural network
I am trying to train a Bayesian neural network, and with 5 inputs and 4 outputs. In the end, I want to have a mean prediction for all the outputs and a estimate of the standard deviation. When I ran the following code, it says that the network must have an output layer. I am wondering whats incorrect. I have followed this example.
numResponses = 4; % y1 y2 y3 y4
featureDimension = 5; % u1 u2 u3 u4 u5 % with feedback imep
% featureDimension = 4; % u1 u2 u3 u4 u5
maxEpochs = 2; % IMPORTANT PARAMETER
miniBatchSize = 512; % IMPORTANT PARAMETER
addpath(‘C:Usersvasu3DocumentsMATLABExamplesR2024annetTrainBayesianNeuralNetworkUsingBayesByBackpropExample’)
% architecture
Networklayer_h2df = […
sequenceInputLayer(featureDimension)
fullyConnectedLayer(4*numHiddenUnits1)
reluLayer
bayesFullyConnectedLayer(4*numHiddenUnits1,Sigma1=1,Sigma2=0.5)
reluLayer
fullyConnectedLayer(8*numHiddenUnits1)
reluLayer
gruLayer(LSTMStateNum,’OutputMode’,’sequence’,InputWeightsInitializer=’he’,RecurrentWeightsInitializer=’he’)
fullyConnectedLayer(8*numHiddenUnits1)
reluLayer
fullyConnectedLayer(4*numHiddenUnits1)
reluLayer
fullyConnectedLayer(numResponses)
bayesFullyConnectedLayer(numResponses,Sigma1=1,Sigma2=0.5)
];I am trying to train a Bayesian neural network, and with 5 inputs and 4 outputs. In the end, I want to have a mean prediction for all the outputs and a estimate of the standard deviation. When I ran the following code, it says that the network must have an output layer. I am wondering whats incorrect. I have followed this example.
numResponses = 4; % y1 y2 y3 y4
featureDimension = 5; % u1 u2 u3 u4 u5 % with feedback imep
% featureDimension = 4; % u1 u2 u3 u4 u5
maxEpochs = 2; % IMPORTANT PARAMETER
miniBatchSize = 512; % IMPORTANT PARAMETER
addpath(‘C:Usersvasu3DocumentsMATLABExamplesR2024annetTrainBayesianNeuralNetworkUsingBayesByBackpropExample’)
% architecture
Networklayer_h2df = […
sequenceInputLayer(featureDimension)
fullyConnectedLayer(4*numHiddenUnits1)
reluLayer
bayesFullyConnectedLayer(4*numHiddenUnits1,Sigma1=1,Sigma2=0.5)
reluLayer
fullyConnectedLayer(8*numHiddenUnits1)
reluLayer
gruLayer(LSTMStateNum,’OutputMode’,’sequence’,InputWeightsInitializer=’he’,RecurrentWeightsInitializer=’he’)
fullyConnectedLayer(8*numHiddenUnits1)
reluLayer
fullyConnectedLayer(4*numHiddenUnits1)
reluLayer
fullyConnectedLayer(numResponses)
bayesFullyConnectedLayer(numResponses,Sigma1=1,Sigma2=0.5)
]; I am trying to train a Bayesian neural network, and with 5 inputs and 4 outputs. In the end, I want to have a mean prediction for all the outputs and a estimate of the standard deviation. When I ran the following code, it says that the network must have an output layer. I am wondering whats incorrect. I have followed this example.
numResponses = 4; % y1 y2 y3 y4
featureDimension = 5; % u1 u2 u3 u4 u5 % with feedback imep
% featureDimension = 4; % u1 u2 u3 u4 u5
maxEpochs = 2; % IMPORTANT PARAMETER
miniBatchSize = 512; % IMPORTANT PARAMETER
addpath(‘C:Usersvasu3DocumentsMATLABExamplesR2024annetTrainBayesianNeuralNetworkUsingBayesByBackpropExample’)
% architecture
Networklayer_h2df = […
sequenceInputLayer(featureDimension)
fullyConnectedLayer(4*numHiddenUnits1)
reluLayer
bayesFullyConnectedLayer(4*numHiddenUnits1,Sigma1=1,Sigma2=0.5)
reluLayer
fullyConnectedLayer(8*numHiddenUnits1)
reluLayer
gruLayer(LSTMStateNum,’OutputMode’,’sequence’,InputWeightsInitializer=’he’,RecurrentWeightsInitializer=’he’)
fullyConnectedLayer(8*numHiddenUnits1)
reluLayer
fullyConnectedLayer(4*numHiddenUnits1)
reluLayer
fullyConnectedLayer(numResponses)
bayesFullyConnectedLayer(numResponses,Sigma1=1,Sigma2=0.5)
]; deep learning, machine learning, neural network MATLAB Answers — New Questions
How to make a specific bar to be hatched with a specific color
I have the array y1 which consists of 5 sets, and each set consists of 6 elements. For example, the first set is 0.25 1.14 2.20 0.21 1.09 2.16. I need to make the last three elements in each set to be cross hatched with a specific color I choose.. how can I make it. my code is below
x=[1,2,3,4,5];
y1=[0.25 1.14 2.20 0.21 1.09 2.16 ; 0.48 2.26 4.40 0.42 2.20 4.34; 0.72 3.38 6.58 0.74 3.27 5.86 ;1.01 4.56 8.82 0.99 4.34 7.65;1.33 5.76 11.04 1.33 5.50 9.61 ]
figure
h1 = bar(y1);
set(h1, {‘DisplayName’}, {‘textbf{Proposed framework without AES}’,’textbf{Proposed framework with AES-128}’,’textbf{Proposed framework with AES-256}’,’textbf{Delay-energy-aware without AES}’,’textbf{Delay-energy-aware with AES-128}’,’textbf{Delay-energy-aware with AES-256}’}’)
set(gca,’TickLabelInterpreter’,’latex’, ‘LineWidth’, 1,’FontSize’,12, ‘YMinorTick’,’on’);
legend(‘Location’,’northwest’,’Interpreter’,’latex’, ‘FontWeight’,’bold’,’FontSize’,9.5,…
‘FontName’,’Palatino Linotype’,…
‘Location’,’best’);
xlabel(‘$textbf{Number of tasks}$’,’FontWeight’,’bold’,’FontSize’,12,…
‘FontName’,’Palatino Linotype’,’Interpreter’,’latex’);
ylabel(‘$textbf{Total delay [S]}$’,’FontWeight’,’bold’,’FontSize’,12,…
‘FontName’,’Palatino Linotype’,’Interpreter’,’latex’);I have the array y1 which consists of 5 sets, and each set consists of 6 elements. For example, the first set is 0.25 1.14 2.20 0.21 1.09 2.16. I need to make the last three elements in each set to be cross hatched with a specific color I choose.. how can I make it. my code is below
x=[1,2,3,4,5];
y1=[0.25 1.14 2.20 0.21 1.09 2.16 ; 0.48 2.26 4.40 0.42 2.20 4.34; 0.72 3.38 6.58 0.74 3.27 5.86 ;1.01 4.56 8.82 0.99 4.34 7.65;1.33 5.76 11.04 1.33 5.50 9.61 ]
figure
h1 = bar(y1);
set(h1, {‘DisplayName’}, {‘textbf{Proposed framework without AES}’,’textbf{Proposed framework with AES-128}’,’textbf{Proposed framework with AES-256}’,’textbf{Delay-energy-aware without AES}’,’textbf{Delay-energy-aware with AES-128}’,’textbf{Delay-energy-aware with AES-256}’}’)
set(gca,’TickLabelInterpreter’,’latex’, ‘LineWidth’, 1,’FontSize’,12, ‘YMinorTick’,’on’);
legend(‘Location’,’northwest’,’Interpreter’,’latex’, ‘FontWeight’,’bold’,’FontSize’,9.5,…
‘FontName’,’Palatino Linotype’,…
‘Location’,’best’);
xlabel(‘$textbf{Number of tasks}$’,’FontWeight’,’bold’,’FontSize’,12,…
‘FontName’,’Palatino Linotype’,’Interpreter’,’latex’);
ylabel(‘$textbf{Total delay [S]}$’,’FontWeight’,’bold’,’FontSize’,12,…
‘FontName’,’Palatino Linotype’,’Interpreter’,’latex’); I have the array y1 which consists of 5 sets, and each set consists of 6 elements. For example, the first set is 0.25 1.14 2.20 0.21 1.09 2.16. I need to make the last three elements in each set to be cross hatched with a specific color I choose.. how can I make it. my code is below
x=[1,2,3,4,5];
y1=[0.25 1.14 2.20 0.21 1.09 2.16 ; 0.48 2.26 4.40 0.42 2.20 4.34; 0.72 3.38 6.58 0.74 3.27 5.86 ;1.01 4.56 8.82 0.99 4.34 7.65;1.33 5.76 11.04 1.33 5.50 9.61 ]
figure
h1 = bar(y1);
set(h1, {‘DisplayName’}, {‘textbf{Proposed framework without AES}’,’textbf{Proposed framework with AES-128}’,’textbf{Proposed framework with AES-256}’,’textbf{Delay-energy-aware without AES}’,’textbf{Delay-energy-aware with AES-128}’,’textbf{Delay-energy-aware with AES-256}’}’)
set(gca,’TickLabelInterpreter’,’latex’, ‘LineWidth’, 1,’FontSize’,12, ‘YMinorTick’,’on’);
legend(‘Location’,’northwest’,’Interpreter’,’latex’, ‘FontWeight’,’bold’,’FontSize’,9.5,…
‘FontName’,’Palatino Linotype’,…
‘Location’,’best’);
xlabel(‘$textbf{Number of tasks}$’,’FontWeight’,’bold’,’FontSize’,12,…
‘FontName’,’Palatino Linotype’,’Interpreter’,’latex’);
ylabel(‘$textbf{Total delay [S]}$’,’FontWeight’,’bold’,’FontSize’,12,…
‘FontName’,’Palatino Linotype’,’Interpreter’,’latex’); hatched bars, matlab bars, matlab MATLAB Answers — New Questions
Multi input convolutional neural network
How to implement three stream convolutional neural network. I was tried to use the following file exchange which is the implementation of two stream CNN using digit database.
https://jp.mathworks.com/matlabcentral/fileexchange/74760-image-classification-using-cnn-with-multi-input
But my database in folder format. Above file exchange use the digitTrain4Darray as the input in which the images are stored in the table and corresponding label is stored in the table in array format. But i don’t know how to map my database to the code provided in the file exchange.
my database contains 50 subfolders represents the 50 classes. Each class contains the 6 image. I have to use 4 images for training and 2 images for testing.
Similarly i have to 2 more database in same format.
I need to train my CNN with these three database separately. Finally i have to concatenate the results as in the image.
Kindly suggest the ways to do this task.
Thanks and regards,
Ramasenthil.How to implement three stream convolutional neural network. I was tried to use the following file exchange which is the implementation of two stream CNN using digit database.
https://jp.mathworks.com/matlabcentral/fileexchange/74760-image-classification-using-cnn-with-multi-input
But my database in folder format. Above file exchange use the digitTrain4Darray as the input in which the images are stored in the table and corresponding label is stored in the table in array format. But i don’t know how to map my database to the code provided in the file exchange.
my database contains 50 subfolders represents the 50 classes. Each class contains the 6 image. I have to use 4 images for training and 2 images for testing.
Similarly i have to 2 more database in same format.
I need to train my CNN with these three database separately. Finally i have to concatenate the results as in the image.
Kindly suggest the ways to do this task.
Thanks and regards,
Ramasenthil. How to implement three stream convolutional neural network. I was tried to use the following file exchange which is the implementation of two stream CNN using digit database.
https://jp.mathworks.com/matlabcentral/fileexchange/74760-image-classification-using-cnn-with-multi-input
But my database in folder format. Above file exchange use the digitTrain4Darray as the input in which the images are stored in the table and corresponding label is stored in the table in array format. But i don’t know how to map my database to the code provided in the file exchange.
my database contains 50 subfolders represents the 50 classes. Each class contains the 6 image. I have to use 4 images for training and 2 images for testing.
Similarly i have to 2 more database in same format.
I need to train my CNN with these three database separately. Finally i have to concatenate the results as in the image.
Kindly suggest the ways to do this task.
Thanks and regards,
Ramasenthil. multi input cnn, deep learning, cnn, input layer, image input, concatenation, multi stream cnn, deep learning toolbox, data import, data augmentation, cnn training, image database, convolutional neural network, image processing, image classification, table array MATLAB Answers — New Questions
How can I model a nearly complicated robotic system?
I am trying to model a 5 DOF robotic system to evaluate my driven kinematic and geometric modelling but this robot includes 5 kinematic chains that makes it somekind of complicated. Also the fact that I am new to robotic modelling adds up to it. I tried to design cad model of robot in Solidworks and import it to matlab simulink using
smimport
command but without getting any errors, my model doesn’t work properly. Everytime I try to fix the model and run the simulink model, I face new problems such as most of the joints not moving or broken assembly. Also I cannot add it to workspace with the command
importrobot
I get some errors like "Targets or motion inputs are specified for every joint around a kinematic loop". I’ll attach the picture of robot model, its simulink generated model and file of simulink and Solidworks model. I’ll be so grateful if anyone could help me or give me a hint.
and all of the related files are in a attached zip fileI am trying to model a 5 DOF robotic system to evaluate my driven kinematic and geometric modelling but this robot includes 5 kinematic chains that makes it somekind of complicated. Also the fact that I am new to robotic modelling adds up to it. I tried to design cad model of robot in Solidworks and import it to matlab simulink using
smimport
command but without getting any errors, my model doesn’t work properly. Everytime I try to fix the model and run the simulink model, I face new problems such as most of the joints not moving or broken assembly. Also I cannot add it to workspace with the command
importrobot
I get some errors like "Targets or motion inputs are specified for every joint around a kinematic loop". I’ll attach the picture of robot model, its simulink generated model and file of simulink and Solidworks model. I’ll be so grateful if anyone could help me or give me a hint.
and all of the related files are in a attached zip file I am trying to model a 5 DOF robotic system to evaluate my driven kinematic and geometric modelling but this robot includes 5 kinematic chains that makes it somekind of complicated. Also the fact that I am new to robotic modelling adds up to it. I tried to design cad model of robot in Solidworks and import it to matlab simulink using
smimport
command but without getting any errors, my model doesn’t work properly. Everytime I try to fix the model and run the simulink model, I face new problems such as most of the joints not moving or broken assembly. Also I cannot add it to workspace with the command
importrobot
I get some errors like "Targets or motion inputs are specified for every joint around a kinematic loop". I’ll attach the picture of robot model, its simulink generated model and file of simulink and Solidworks model. I’ll be so grateful if anyone could help me or give me a hint.
and all of the related files are in a attached zip file matlab, simulink, robotic, modelling, simulation, simscape, rigidboytree, robot MATLAB Answers — New Questions
How to calculate the poles of the fractional transfer function
This is my fractional transfer fucnction, I want to draw the poles of the transfer function. I tried to use the FOMCON toolbox, but there is no pzmap function.How should I do?
———
clear;clc;
s=fotf(‘s’);
lamda1=0.8;
lamda2=0.8;
w0=300;
alpha1=2*w0;
alpha2=w0^2;
beta1=2*w0;
beta2=w0^2;
k=60;
r=1;
h1=s^(lamda1+1)+alpha1*s^(lamda1)+alpha2;
h2=s^(lamda2+1)+beta1*s^(lamda2)+beta2;
m1=h1*h2-h2*alpha2-h1*beta2+beta2*(s^(lamda1+1)+alpha2);
m2=h1*h2*k+alpha2*h2*s+alpha1*beta2*s^(lamda1+1);
G=k*h1*h2/(r*m1*s+m2);
——
where G is the transfer function.This is my fractional transfer fucnction, I want to draw the poles of the transfer function. I tried to use the FOMCON toolbox, but there is no pzmap function.How should I do?
———
clear;clc;
s=fotf(‘s’);
lamda1=0.8;
lamda2=0.8;
w0=300;
alpha1=2*w0;
alpha2=w0^2;
beta1=2*w0;
beta2=w0^2;
k=60;
r=1;
h1=s^(lamda1+1)+alpha1*s^(lamda1)+alpha2;
h2=s^(lamda2+1)+beta1*s^(lamda2)+beta2;
m1=h1*h2-h2*alpha2-h1*beta2+beta2*(s^(lamda1+1)+alpha2);
m2=h1*h2*k+alpha2*h2*s+alpha1*beta2*s^(lamda1+1);
G=k*h1*h2/(r*m1*s+m2);
——
where G is the transfer function. This is my fractional transfer fucnction, I want to draw the poles of the transfer function. I tried to use the FOMCON toolbox, but there is no pzmap function.How should I do?
———
clear;clc;
s=fotf(‘s’);
lamda1=0.8;
lamda2=0.8;
w0=300;
alpha1=2*w0;
alpha2=w0^2;
beta1=2*w0;
beta2=w0^2;
k=60;
r=1;
h1=s^(lamda1+1)+alpha1*s^(lamda1)+alpha2;
h2=s^(lamda2+1)+beta1*s^(lamda2)+beta2;
m1=h1*h2-h2*alpha2-h1*beta2+beta2*(s^(lamda1+1)+alpha2);
m2=h1*h2*k+alpha2*h2*s+alpha1*beta2*s^(lamda1+1);
G=k*h1*h2/(r*m1*s+m2);
——
where G is the transfer function. pole, fractional, transfer function, pzmap MATLAB Answers — New Questions
How to Clean the MATLAB Runtime (MCR) Cache?
How can I clean MATLAB Runtime cache?How can I clean MATLAB Runtime cache? How can I clean MATLAB Runtime cache? MATLAB Answers — New Questions
Why do I get the error “Unrecognized function or variable ‘ctfroot'” when running “MATLABWebAppServer.exe”?
Why do I get the error "Unrecognized function or variable ‘ctfroot’" when running the Development version of MATLAB Web App Server – "MATLABWebAppServer.exe"?
Here is a screenshot of the exact error:Why do I get the error "Unrecognized function or variable ‘ctfroot’" when running the Development version of MATLAB Web App Server – "MATLABWebAppServer.exe"?
Here is a screenshot of the exact error: Why do I get the error "Unrecognized function or variable ‘ctfroot’" when running the Development version of MATLAB Web App Server – "MATLABWebAppServer.exe"?
Here is a screenshot of the exact error: matlabwebappserver, ctfroot, unrecognized, web, app, server MATLAB Answers — New Questions
RMSE in Fuzzy logic designer
I can’t find any information about how the Fuzzy Logic Designer toolbox calculates the RMSE. Does anyone know how it’s done?I can’t find any information about how the Fuzzy Logic Designer toolbox calculates the RMSE. Does anyone know how it’s done? I can’t find any information about how the Fuzzy Logic Designer toolbox calculates the RMSE. Does anyone know how it’s done? rmse, fuzzy MATLAB Answers — New Questions
integrate with the upper limit is a function
Hello!
How to integrate a function on Matlab with the upper limit is a function, for exemple the following integral:
i tried this code:
U= vpa(int(f,s,0,t^2))
but it returns int(f,s,0,t^2)!!
is there any method to do it?Hello!
How to integrate a function on Matlab with the upper limit is a function, for exemple the following integral:
i tried this code:
U= vpa(int(f,s,0,t^2))
but it returns int(f,s,0,t^2)!!
is there any method to do it? Hello!
How to integrate a function on Matlab with the upper limit is a function, for exemple the following integral:
i tried this code:
U= vpa(int(f,s,0,t^2))
but it returns int(f,s,0,t^2)!!
is there any method to do it? integral, numerical integration MATLAB Answers — New Questions
MATLAB only plotting most recent graph
I don’t understand why matlab is only plotting figure 2
t0 = 0; tf = 50; y0 = [-0.5;0.5];
[t,Y] = ode45(@f,[t0,tf],y0,[]);
y=Y(:,1);v=Y(:,2);
[t,Y(:,1),Y(:,2)];
% y in output has 2 columns corresponding to u1 and u2
figure(1);
plot(t, y,’b-‘, t,v,’r-‘ )
xlabel(‘t’); ylabel(‘y, v = y”’);
legend(‘y(t)’,’v(t)’)
ylim([-2.5,2.5]);xticks(0:10:50);
grid on
figure(2);
plot(y,v); axis square; xlabel(‘y’); ylabel(‘v=y”’);
ylim([-2.5,2.5])
xlim([-2.5,2.5])
grid on
hold off
% plot the phase plot %———————————————————————-
function dydt = f(t,Y)
y = Y(1); v = Y(2);
dydt = [v;-2*sin(t)-v-2*y ];
endI don’t understand why matlab is only plotting figure 2
t0 = 0; tf = 50; y0 = [-0.5;0.5];
[t,Y] = ode45(@f,[t0,tf],y0,[]);
y=Y(:,1);v=Y(:,2);
[t,Y(:,1),Y(:,2)];
% y in output has 2 columns corresponding to u1 and u2
figure(1);
plot(t, y,’b-‘, t,v,’r-‘ )
xlabel(‘t’); ylabel(‘y, v = y”’);
legend(‘y(t)’,’v(t)’)
ylim([-2.5,2.5]);xticks(0:10:50);
grid on
figure(2);
plot(y,v); axis square; xlabel(‘y’); ylabel(‘v=y”’);
ylim([-2.5,2.5])
xlim([-2.5,2.5])
grid on
hold off
% plot the phase plot %———————————————————————-
function dydt = f(t,Y)
y = Y(1); v = Y(2);
dydt = [v;-2*sin(t)-v-2*y ];
end I don’t understand why matlab is only plotting figure 2
t0 = 0; tf = 50; y0 = [-0.5;0.5];
[t,Y] = ode45(@f,[t0,tf],y0,[]);
y=Y(:,1);v=Y(:,2);
[t,Y(:,1),Y(:,2)];
% y in output has 2 columns corresponding to u1 and u2
figure(1);
plot(t, y,’b-‘, t,v,’r-‘ )
xlabel(‘t’); ylabel(‘y, v = y”’);
legend(‘y(t)’,’v(t)’)
ylim([-2.5,2.5]);xticks(0:10:50);
grid on
figure(2);
plot(y,v); axis square; xlabel(‘y’); ylabel(‘v=y”’);
ylim([-2.5,2.5])
xlim([-2.5,2.5])
grid on
hold off
% plot the phase plot %———————————————————————-
function dydt = f(t,Y)
y = Y(1); v = Y(2);
dydt = [v;-2*sin(t)-v-2*y ];
end graph problem MATLAB Answers — New Questions
uilabel – fit width to text
Hi,
I have some uilabel objectss in my appdesigner app which are created programmatically while the app is running.
Now I would like to change the size of the uilabel in a way that it fits the text and does not cut it off. How can I do that?
Googling gave me only some information on how to do that with uicontrol objects via the ‘Extent’ property. Unfortunately, uilabel objects do not have such a property and uicontrols don’t work with appdesigner.
I would also be interested in how to fit the label size when the fontsize changes. Maybe that could be done using the same means.Hi,
I have some uilabel objectss in my appdesigner app which are created programmatically while the app is running.
Now I would like to change the size of the uilabel in a way that it fits the text and does not cut it off. How can I do that?
Googling gave me only some information on how to do that with uicontrol objects via the ‘Extent’ property. Unfortunately, uilabel objects do not have such a property and uicontrols don’t work with appdesigner.
I would also be interested in how to fit the label size when the fontsize changes. Maybe that could be done using the same means. Hi,
I have some uilabel objectss in my appdesigner app which are created programmatically while the app is running.
Now I would like to change the size of the uilabel in a way that it fits the text and does not cut it off. How can I do that?
Googling gave me only some information on how to do that with uicontrol objects via the ‘Extent’ property. Unfortunately, uilabel objects do not have such a property and uicontrols don’t work with appdesigner.
I would also be interested in how to fit the label size when the fontsize changes. Maybe that could be done using the same means. appdesigner, uilabel MATLAB Answers — New Questions
What happened to the figure palette plot browser for 2024B?
What happened to the figure palette plot browser for 2024B? In 2023 version and before it, I can type figure then with the figure palette I can add an axes and then add data to the plot for quickly looking at data in a mat file. Is this all gone, how is it replaced?What happened to the figure palette plot browser for 2024B? In 2023 version and before it, I can type figure then with the figure palette I can add an axes and then add data to the plot for quickly looking at data in a mat file. Is this all gone, how is it replaced? What happened to the figure palette plot browser for 2024B? In 2023 version and before it, I can type figure then with the figure palette I can add an axes and then add data to the plot for quickly looking at data in a mat file. Is this all gone, how is it replaced? figure axes palette MATLAB Answers — New Questions
How to resize uitable?
I have a uitable extracting data from a database in my GUI which is displayed upon a click of a button.
I am sending 3 columns of data, however only one column appears with a horizontal scroll bar. I want the table to re-adjust the size depending on he number of columns sent as this can be seleced from 1-3.
Here is my code so far:
FinalOut = [Output, Output2, Output3];
disp(FinalOut);
ColNames = {TableType; TableType2; TableType3};
disp(ColNames);
uitable(handles.figure1,’Data’,FinalOut,’ColumnName’,ColNames,’Position’,[250 20 150 300]);
Is there a way to make this table more flexible/dynamic depending on the columns of data sent, so the width of the table only is changed as data is loaded in?I have a uitable extracting data from a database in my GUI which is displayed upon a click of a button.
I am sending 3 columns of data, however only one column appears with a horizontal scroll bar. I want the table to re-adjust the size depending on he number of columns sent as this can be seleced from 1-3.
Here is my code so far:
FinalOut = [Output, Output2, Output3];
disp(FinalOut);
ColNames = {TableType; TableType2; TableType3};
disp(ColNames);
uitable(handles.figure1,’Data’,FinalOut,’ColumnName’,ColNames,’Position’,[250 20 150 300]);
Is there a way to make this table more flexible/dynamic depending on the columns of data sent, so the width of the table only is changed as data is loaded in? I have a uitable extracting data from a database in my GUI which is displayed upon a click of a button.
I am sending 3 columns of data, however only one column appears with a horizontal scroll bar. I want the table to re-adjust the size depending on he number of columns sent as this can be seleced from 1-3.
Here is my code so far:
FinalOut = [Output, Output2, Output3];
disp(FinalOut);
ColNames = {TableType; TableType2; TableType3};
disp(ColNames);
uitable(handles.figure1,’Data’,FinalOut,’ColumnName’,ColNames,’Position’,[250 20 150 300]);
Is there a way to make this table more flexible/dynamic depending on the columns of data sent, so the width of the table only is changed as data is loaded in? uitable, gui, mysql MATLAB Answers — New Questions