Category: Matlab
Category Archives: Matlab
sbiofit ability to estimate the parameter for 3 different cases at the same time
Hi,
I wrote the code below for estimation of KD from the binding assay for three different cell lines: i.e. bxpc3, colo205, T84 which have different number of antigen molecule on their surface. The code properly work for estimation of kD spearately for each cell line.
How can I estimate the kD as one value for different cell lines at the same time?
I attached my excel file (exp.xlsx) in which each cell line data has been stored in a spearted sheet.
Thanks
%% Setup Model
case_study = ‘T84’; % ‘bxpc3’ ‘colo205’ ‘T84’
model_input_file=’exp.xlsx’
switch case_study
case ‘bxpc3’
exp_data=readtable(model_input_file,’Sheet’,’bxpc3′);
data.dose = exp_data.dose;
data.ro = exp_data.RO_exp;
input1=[0.1 0.4 1.2 11.1 33.3 100 300];
RPC_Ag_Tumor = 219202;
case ‘colo205’
exp_data=readtable(model_input_file,’Sheet’,’colo205′);
data.dose = exp_data.dose;
data.ro = exp_data.RO_exp;
input1=[0.1 0.4 1.2 3.7 11.1 33.3 100];
RPC_Ag_Tumor = 662642;
case ‘T84’
exp_data=readtable(model_input_file,’Sheet’,’T84′);
data.dose = exp_data.dose;
data.ro = exp_data.RO_exp;
input1=[0.1 0.4 1.2 3.7 11.1 33.3 100 300];
RPC_Ag_Tumor = 169163;
end
data = structfun( @rmmissing , data , ‘UniformOutput’ , false);
setup; % (I build the model here)
%% Data Import
gData = groupedData(exp_data);
gData.Properties.VariableUnits = {”,’second’,’nanomole’,’dimensionless’};
gData.Properties.GroupVariableName = ‘ID’;
gData.Properties.IndependentVariableName = ‘Time’;
sbiotrellis(gData,’ID’,’Time’,{‘RO_exp’},’Marker’,’+’,’LineStyle’,’none’);
% Extract data columns into separate variables for the weight expression
% evaluation.
headings = exp_data.Properties.VariableNames;
for i=1:length(headings)
next = headings{i};
eval([next ‘ = exp_data. ‘ next ‘;’]);
end
%% Create the data dose.
d2 = sbiodose(‘dose’);
d2.TargetName = ‘Ab’;
d2.LagParameterName = ”;
d2 = createDoses(gData, ‘dose’, ”, d2);
% Build table of doses.
d2 = num2cell(d2);
dosesForFit = d2;
%% Fitting options
% Define response information.
responseMap = {‘RO = RO_exp’};
% Define objects being estimated and their initial estimates.
estimatedInfoObj = estimatedInfo({‘kD_Ab’});
% estimatedInfoObj = estimatedInfo({‘k_max’, ‘EC50’});
estimatedInfoObj(1).Bounds = [1E-1 1E2];
% estimatedInfoObj(2).Bounds = [1E-6 1E-4];
% Define Algorithm options.
options = optimoptions(‘particleswarm’);
options.Display= ‘iter’;
% Define fit problem.
f = fitproblem(‘FitFunction’, ‘sbiofit’);
f.Data = gData;
f.Model = model;
f.Estimated = estimatedInfoObj;
f.ErrorModel = ‘exponential’;
f.ResponseMap = responseMap;
f.Weights = [];
f.Doses = dosesForFit;
f.FunctionName = ‘particleswarm’;
f.Options = options;
f.ProgressPlot = true;
f.UseParallel = false;
f.Pooled = true;
%% Run the model with optimum parameters
fitResults = f.fit;
plot(fitResults)
ci = sbiopredictionci(fitResults);
plot(ci)
ciParam = sbioparameterci(fitResults);
ci2table(ciParam)
plot(ciParam)
fitResults.ParameterEstimates
%update parameters
for i=1:length(estimatedInfoObj)
xopt = sbioselect(model,’Name’,fitResults.EstimatedParameterNames{i});
xopt.value = fitResults.ParameterEstimates.Estimate(i);
end
params = {‘Ab0’};
obs = {‘RO’};
input=dose(~isnan(dose));
RO_exp = RO_exp(~isnan(RO_exp));
sfxn = createSimFunction(model, params, obs, d1,’UseParallel’,false,’AutoAccelerate’,false);
sfxn.accelerate;
doseTable = getTable(d1);
simData=sfxn(input,configsetObj.StopTime,doseTable);
%% Plot
fontsize = 18;
linesize = 2;
markersize = 10;
f = figure(‘Position’, [14 10 900 600]);
colors = ["k", "#D95319", "#A2142F", "#77AC30", "#7E2F8E", "#00CED1", "#FF1493"]; % Define an array of colors
set(f, ‘Visible’, ‘on’);
set(gca,’fontsize’, fontsize);
hold on;
box on;
grid on;
set(gca, ‘XScale’, ‘log’);
%set(gca, ‘YScale’, ‘log’);
for i = 1:size(input,1)
if i < size(input,1)
line([input1(i) input1(i+1)], [simData(i).Data(end) simData(i+1).Data(end)], ‘Color’, colors(3),’LineWidth’, 2);
end
% plot(input1(i), simData(i).Data(end), ‘O’, ‘MarkerEdgeColor’, colors(3), ‘MarkerFaceColor’, colors(3), ‘markersize’, markersize);
plot(input1(i), RO_exp(i), ‘O’, ‘MarkerEdgeColor’, colors(4), ‘MarkerFaceColor’, colors(4), ‘markersize’, markersize);
end
xlabel(‘Dose (ug/mL)’, ‘fontweight’, ‘bold’, ‘Fontsize’, fontsize, ‘Interpreter’, ‘none’);
ylabel(‘RO (%)’, ‘fontweight’, ‘bold’, ‘Fontsize’, fontsize);
legend(‘Simulation’,’Experiment’ , ‘NumColumns’, 1, ‘Location’, ‘best’, ‘FontSize’, fontsize)
saveas(gca, fullfile(save_locations{2}, ‘RO’), ‘png’);
close(f);Hi,
I wrote the code below for estimation of KD from the binding assay for three different cell lines: i.e. bxpc3, colo205, T84 which have different number of antigen molecule on their surface. The code properly work for estimation of kD spearately for each cell line.
How can I estimate the kD as one value for different cell lines at the same time?
I attached my excel file (exp.xlsx) in which each cell line data has been stored in a spearted sheet.
Thanks
%% Setup Model
case_study = ‘T84’; % ‘bxpc3’ ‘colo205’ ‘T84’
model_input_file=’exp.xlsx’
switch case_study
case ‘bxpc3’
exp_data=readtable(model_input_file,’Sheet’,’bxpc3′);
data.dose = exp_data.dose;
data.ro = exp_data.RO_exp;
input1=[0.1 0.4 1.2 11.1 33.3 100 300];
RPC_Ag_Tumor = 219202;
case ‘colo205’
exp_data=readtable(model_input_file,’Sheet’,’colo205′);
data.dose = exp_data.dose;
data.ro = exp_data.RO_exp;
input1=[0.1 0.4 1.2 3.7 11.1 33.3 100];
RPC_Ag_Tumor = 662642;
case ‘T84’
exp_data=readtable(model_input_file,’Sheet’,’T84′);
data.dose = exp_data.dose;
data.ro = exp_data.RO_exp;
input1=[0.1 0.4 1.2 3.7 11.1 33.3 100 300];
RPC_Ag_Tumor = 169163;
end
data = structfun( @rmmissing , data , ‘UniformOutput’ , false);
setup; % (I build the model here)
%% Data Import
gData = groupedData(exp_data);
gData.Properties.VariableUnits = {”,’second’,’nanomole’,’dimensionless’};
gData.Properties.GroupVariableName = ‘ID’;
gData.Properties.IndependentVariableName = ‘Time’;
sbiotrellis(gData,’ID’,’Time’,{‘RO_exp’},’Marker’,’+’,’LineStyle’,’none’);
% Extract data columns into separate variables for the weight expression
% evaluation.
headings = exp_data.Properties.VariableNames;
for i=1:length(headings)
next = headings{i};
eval([next ‘ = exp_data. ‘ next ‘;’]);
end
%% Create the data dose.
d2 = sbiodose(‘dose’);
d2.TargetName = ‘Ab’;
d2.LagParameterName = ”;
d2 = createDoses(gData, ‘dose’, ”, d2);
% Build table of doses.
d2 = num2cell(d2);
dosesForFit = d2;
%% Fitting options
% Define response information.
responseMap = {‘RO = RO_exp’};
% Define objects being estimated and their initial estimates.
estimatedInfoObj = estimatedInfo({‘kD_Ab’});
% estimatedInfoObj = estimatedInfo({‘k_max’, ‘EC50’});
estimatedInfoObj(1).Bounds = [1E-1 1E2];
% estimatedInfoObj(2).Bounds = [1E-6 1E-4];
% Define Algorithm options.
options = optimoptions(‘particleswarm’);
options.Display= ‘iter’;
% Define fit problem.
f = fitproblem(‘FitFunction’, ‘sbiofit’);
f.Data = gData;
f.Model = model;
f.Estimated = estimatedInfoObj;
f.ErrorModel = ‘exponential’;
f.ResponseMap = responseMap;
f.Weights = [];
f.Doses = dosesForFit;
f.FunctionName = ‘particleswarm’;
f.Options = options;
f.ProgressPlot = true;
f.UseParallel = false;
f.Pooled = true;
%% Run the model with optimum parameters
fitResults = f.fit;
plot(fitResults)
ci = sbiopredictionci(fitResults);
plot(ci)
ciParam = sbioparameterci(fitResults);
ci2table(ciParam)
plot(ciParam)
fitResults.ParameterEstimates
%update parameters
for i=1:length(estimatedInfoObj)
xopt = sbioselect(model,’Name’,fitResults.EstimatedParameterNames{i});
xopt.value = fitResults.ParameterEstimates.Estimate(i);
end
params = {‘Ab0’};
obs = {‘RO’};
input=dose(~isnan(dose));
RO_exp = RO_exp(~isnan(RO_exp));
sfxn = createSimFunction(model, params, obs, d1,’UseParallel’,false,’AutoAccelerate’,false);
sfxn.accelerate;
doseTable = getTable(d1);
simData=sfxn(input,configsetObj.StopTime,doseTable);
%% Plot
fontsize = 18;
linesize = 2;
markersize = 10;
f = figure(‘Position’, [14 10 900 600]);
colors = ["k", "#D95319", "#A2142F", "#77AC30", "#7E2F8E", "#00CED1", "#FF1493"]; % Define an array of colors
set(f, ‘Visible’, ‘on’);
set(gca,’fontsize’, fontsize);
hold on;
box on;
grid on;
set(gca, ‘XScale’, ‘log’);
%set(gca, ‘YScale’, ‘log’);
for i = 1:size(input,1)
if i < size(input,1)
line([input1(i) input1(i+1)], [simData(i).Data(end) simData(i+1).Data(end)], ‘Color’, colors(3),’LineWidth’, 2);
end
% plot(input1(i), simData(i).Data(end), ‘O’, ‘MarkerEdgeColor’, colors(3), ‘MarkerFaceColor’, colors(3), ‘markersize’, markersize);
plot(input1(i), RO_exp(i), ‘O’, ‘MarkerEdgeColor’, colors(4), ‘MarkerFaceColor’, colors(4), ‘markersize’, markersize);
end
xlabel(‘Dose (ug/mL)’, ‘fontweight’, ‘bold’, ‘Fontsize’, fontsize, ‘Interpreter’, ‘none’);
ylabel(‘RO (%)’, ‘fontweight’, ‘bold’, ‘Fontsize’, fontsize);
legend(‘Simulation’,’Experiment’ , ‘NumColumns’, 1, ‘Location’, ‘best’, ‘FontSize’, fontsize)
saveas(gca, fullfile(save_locations{2}, ‘RO’), ‘png’);
close(f); Hi,
I wrote the code below for estimation of KD from the binding assay for three different cell lines: i.e. bxpc3, colo205, T84 which have different number of antigen molecule on their surface. The code properly work for estimation of kD spearately for each cell line.
How can I estimate the kD as one value for different cell lines at the same time?
I attached my excel file (exp.xlsx) in which each cell line data has been stored in a spearted sheet.
Thanks
%% Setup Model
case_study = ‘T84’; % ‘bxpc3’ ‘colo205’ ‘T84’
model_input_file=’exp.xlsx’
switch case_study
case ‘bxpc3’
exp_data=readtable(model_input_file,’Sheet’,’bxpc3′);
data.dose = exp_data.dose;
data.ro = exp_data.RO_exp;
input1=[0.1 0.4 1.2 11.1 33.3 100 300];
RPC_Ag_Tumor = 219202;
case ‘colo205’
exp_data=readtable(model_input_file,’Sheet’,’colo205′);
data.dose = exp_data.dose;
data.ro = exp_data.RO_exp;
input1=[0.1 0.4 1.2 3.7 11.1 33.3 100];
RPC_Ag_Tumor = 662642;
case ‘T84’
exp_data=readtable(model_input_file,’Sheet’,’T84′);
data.dose = exp_data.dose;
data.ro = exp_data.RO_exp;
input1=[0.1 0.4 1.2 3.7 11.1 33.3 100 300];
RPC_Ag_Tumor = 169163;
end
data = structfun( @rmmissing , data , ‘UniformOutput’ , false);
setup; % (I build the model here)
%% Data Import
gData = groupedData(exp_data);
gData.Properties.VariableUnits = {”,’second’,’nanomole’,’dimensionless’};
gData.Properties.GroupVariableName = ‘ID’;
gData.Properties.IndependentVariableName = ‘Time’;
sbiotrellis(gData,’ID’,’Time’,{‘RO_exp’},’Marker’,’+’,’LineStyle’,’none’);
% Extract data columns into separate variables for the weight expression
% evaluation.
headings = exp_data.Properties.VariableNames;
for i=1:length(headings)
next = headings{i};
eval([next ‘ = exp_data. ‘ next ‘;’]);
end
%% Create the data dose.
d2 = sbiodose(‘dose’);
d2.TargetName = ‘Ab’;
d2.LagParameterName = ”;
d2 = createDoses(gData, ‘dose’, ”, d2);
% Build table of doses.
d2 = num2cell(d2);
dosesForFit = d2;
%% Fitting options
% Define response information.
responseMap = {‘RO = RO_exp’};
% Define objects being estimated and their initial estimates.
estimatedInfoObj = estimatedInfo({‘kD_Ab’});
% estimatedInfoObj = estimatedInfo({‘k_max’, ‘EC50’});
estimatedInfoObj(1).Bounds = [1E-1 1E2];
% estimatedInfoObj(2).Bounds = [1E-6 1E-4];
% Define Algorithm options.
options = optimoptions(‘particleswarm’);
options.Display= ‘iter’;
% Define fit problem.
f = fitproblem(‘FitFunction’, ‘sbiofit’);
f.Data = gData;
f.Model = model;
f.Estimated = estimatedInfoObj;
f.ErrorModel = ‘exponential’;
f.ResponseMap = responseMap;
f.Weights = [];
f.Doses = dosesForFit;
f.FunctionName = ‘particleswarm’;
f.Options = options;
f.ProgressPlot = true;
f.UseParallel = false;
f.Pooled = true;
%% Run the model with optimum parameters
fitResults = f.fit;
plot(fitResults)
ci = sbiopredictionci(fitResults);
plot(ci)
ciParam = sbioparameterci(fitResults);
ci2table(ciParam)
plot(ciParam)
fitResults.ParameterEstimates
%update parameters
for i=1:length(estimatedInfoObj)
xopt = sbioselect(model,’Name’,fitResults.EstimatedParameterNames{i});
xopt.value = fitResults.ParameterEstimates.Estimate(i);
end
params = {‘Ab0’};
obs = {‘RO’};
input=dose(~isnan(dose));
RO_exp = RO_exp(~isnan(RO_exp));
sfxn = createSimFunction(model, params, obs, d1,’UseParallel’,false,’AutoAccelerate’,false);
sfxn.accelerate;
doseTable = getTable(d1);
simData=sfxn(input,configsetObj.StopTime,doseTable);
%% Plot
fontsize = 18;
linesize = 2;
markersize = 10;
f = figure(‘Position’, [14 10 900 600]);
colors = ["k", "#D95319", "#A2142F", "#77AC30", "#7E2F8E", "#00CED1", "#FF1493"]; % Define an array of colors
set(f, ‘Visible’, ‘on’);
set(gca,’fontsize’, fontsize);
hold on;
box on;
grid on;
set(gca, ‘XScale’, ‘log’);
%set(gca, ‘YScale’, ‘log’);
for i = 1:size(input,1)
if i < size(input,1)
line([input1(i) input1(i+1)], [simData(i).Data(end) simData(i+1).Data(end)], ‘Color’, colors(3),’LineWidth’, 2);
end
% plot(input1(i), simData(i).Data(end), ‘O’, ‘MarkerEdgeColor’, colors(3), ‘MarkerFaceColor’, colors(3), ‘markersize’, markersize);
plot(input1(i), RO_exp(i), ‘O’, ‘MarkerEdgeColor’, colors(4), ‘MarkerFaceColor’, colors(4), ‘markersize’, markersize);
end
xlabel(‘Dose (ug/mL)’, ‘fontweight’, ‘bold’, ‘Fontsize’, fontsize, ‘Interpreter’, ‘none’);
ylabel(‘RO (%)’, ‘fontweight’, ‘bold’, ‘Fontsize’, fontsize);
legend(‘Simulation’,’Experiment’ , ‘NumColumns’, 1, ‘Location’, ‘best’, ‘FontSize’, fontsize)
saveas(gca, fullfile(save_locations{2}, ‘RO’), ‘png’);
close(f); sbiofit, simbiology MATLAB Answers — New Questions
Degrade image with known MTF to another desired MTF
Hi folks,
I want to be able to degrade an image captured by a camera system with known MTF to another hypothetical desired MTF. I thought I would start by blurring an image with a gaussian PSF and try and extract its MTF from the final image.
MTF_output = MTF_input*MTF_blur
Right now, MTF_output and MTF_input can be calculated from the slanted edge image I have. Eventually, I will generate MTF_blur from the desired MTF_output I want. This to prove the math works out.
I calculate MTF_blur two ways.
1) The ratio MTF_output./MTF_input.
2) Extracted from the PSF used to blur the image.
The problem is both methods don’t match.
I think I may be missing something regarding scaling to my optical system or perhaps frequency units. I have no specific camera parameters in this code, although the system is ~3 pixels per degree.
Thanks in advance!
% Read in image and convert to mono double.
img = imread(‘img_input.png’);
img = double(rgb2gray(img));
% Crop to edge and perform slanted edge MTF calc
rect = [308.51 198.51 62.98 51.98];
img_cropped = imcrop(img,rect);
[~, data,~, ~, ~, ~, ~] = sfrmat3(1, 1, [], img_cropped);
freq = data(:,1);
mtf_input = data(:,2);
% Generate PSF used to degrade the image
PSF = fspecial(‘gaussian’,13,1);
% Convert the PSF to an Optical Transfer Function (OTF).
OTF = psf2otf(PSF,[31 31]);
% Extract the MTF from OTF:
MTF_blur_fromPSF = diag(OTF); % Should be circular symmetric, but OTF is a square matrix.
% Blur Image
img_blurred = conv2(img,PSF,’same’); % apply convolution to entire image to avoid edge artifacts
% Crop to edge and perform slanted edge MTF calc
img_blurred_crop = imcrop(img_blurred,rect);
[~, data,~, ~, ~, ~, ~] = sfrmat3(1, 1, [], img_blurred_crop);
freq_output = data(:,1);
mtf_output = data(:,2);
plot(freq, mtf_input); hold on; plot(freq_output, mtf_output);
MTF_blur_fromRatio = mtf_output./mtf_input;
plot(freq,MTF_blur_fromRatio)
axis([0 0.5 0 1])
plot(linspace(0,1,length(MTF_blur_fromPSF)),MTF_blur_fromPSF) % assuming MTF_blur_fromPSF is 0-1 1/pixel units
xlabel(‘Frequency [cy/px]’)
ylabel(‘MTF Response’)
legend(‘Original MTF’,’Blurred MTF’,’MTF_blur_fromRatio’,’MTF_blur_fromPSF’,’Interpreter’, ‘none’)Hi folks,
I want to be able to degrade an image captured by a camera system with known MTF to another hypothetical desired MTF. I thought I would start by blurring an image with a gaussian PSF and try and extract its MTF from the final image.
MTF_output = MTF_input*MTF_blur
Right now, MTF_output and MTF_input can be calculated from the slanted edge image I have. Eventually, I will generate MTF_blur from the desired MTF_output I want. This to prove the math works out.
I calculate MTF_blur two ways.
1) The ratio MTF_output./MTF_input.
2) Extracted from the PSF used to blur the image.
The problem is both methods don’t match.
I think I may be missing something regarding scaling to my optical system or perhaps frequency units. I have no specific camera parameters in this code, although the system is ~3 pixels per degree.
Thanks in advance!
% Read in image and convert to mono double.
img = imread(‘img_input.png’);
img = double(rgb2gray(img));
% Crop to edge and perform slanted edge MTF calc
rect = [308.51 198.51 62.98 51.98];
img_cropped = imcrop(img,rect);
[~, data,~, ~, ~, ~, ~] = sfrmat3(1, 1, [], img_cropped);
freq = data(:,1);
mtf_input = data(:,2);
% Generate PSF used to degrade the image
PSF = fspecial(‘gaussian’,13,1);
% Convert the PSF to an Optical Transfer Function (OTF).
OTF = psf2otf(PSF,[31 31]);
% Extract the MTF from OTF:
MTF_blur_fromPSF = diag(OTF); % Should be circular symmetric, but OTF is a square matrix.
% Blur Image
img_blurred = conv2(img,PSF,’same’); % apply convolution to entire image to avoid edge artifacts
% Crop to edge and perform slanted edge MTF calc
img_blurred_crop = imcrop(img_blurred,rect);
[~, data,~, ~, ~, ~, ~] = sfrmat3(1, 1, [], img_blurred_crop);
freq_output = data(:,1);
mtf_output = data(:,2);
plot(freq, mtf_input); hold on; plot(freq_output, mtf_output);
MTF_blur_fromRatio = mtf_output./mtf_input;
plot(freq,MTF_blur_fromRatio)
axis([0 0.5 0 1])
plot(linspace(0,1,length(MTF_blur_fromPSF)),MTF_blur_fromPSF) % assuming MTF_blur_fromPSF is 0-1 1/pixel units
xlabel(‘Frequency [cy/px]’)
ylabel(‘MTF Response’)
legend(‘Original MTF’,’Blurred MTF’,’MTF_blur_fromRatio’,’MTF_blur_fromPSF’,’Interpreter’, ‘none’) Hi folks,
I want to be able to degrade an image captured by a camera system with known MTF to another hypothetical desired MTF. I thought I would start by blurring an image with a gaussian PSF and try and extract its MTF from the final image.
MTF_output = MTF_input*MTF_blur
Right now, MTF_output and MTF_input can be calculated from the slanted edge image I have. Eventually, I will generate MTF_blur from the desired MTF_output I want. This to prove the math works out.
I calculate MTF_blur two ways.
1) The ratio MTF_output./MTF_input.
2) Extracted from the PSF used to blur the image.
The problem is both methods don’t match.
I think I may be missing something regarding scaling to my optical system or perhaps frequency units. I have no specific camera parameters in this code, although the system is ~3 pixels per degree.
Thanks in advance!
% Read in image and convert to mono double.
img = imread(‘img_input.png’);
img = double(rgb2gray(img));
% Crop to edge and perform slanted edge MTF calc
rect = [308.51 198.51 62.98 51.98];
img_cropped = imcrop(img,rect);
[~, data,~, ~, ~, ~, ~] = sfrmat3(1, 1, [], img_cropped);
freq = data(:,1);
mtf_input = data(:,2);
% Generate PSF used to degrade the image
PSF = fspecial(‘gaussian’,13,1);
% Convert the PSF to an Optical Transfer Function (OTF).
OTF = psf2otf(PSF,[31 31]);
% Extract the MTF from OTF:
MTF_blur_fromPSF = diag(OTF); % Should be circular symmetric, but OTF is a square matrix.
% Blur Image
img_blurred = conv2(img,PSF,’same’); % apply convolution to entire image to avoid edge artifacts
% Crop to edge and perform slanted edge MTF calc
img_blurred_crop = imcrop(img_blurred,rect);
[~, data,~, ~, ~, ~, ~] = sfrmat3(1, 1, [], img_blurred_crop);
freq_output = data(:,1);
mtf_output = data(:,2);
plot(freq, mtf_input); hold on; plot(freq_output, mtf_output);
MTF_blur_fromRatio = mtf_output./mtf_input;
plot(freq,MTF_blur_fromRatio)
axis([0 0.5 0 1])
plot(linspace(0,1,length(MTF_blur_fromPSF)),MTF_blur_fromPSF) % assuming MTF_blur_fromPSF is 0-1 1/pixel units
xlabel(‘Frequency [cy/px]’)
ylabel(‘MTF Response’)
legend(‘Original MTF’,’Blurred MTF’,’MTF_blur_fromRatio’,’MTF_blur_fromPSF’,’Interpreter’, ‘none’) image analysis, simulation, mtf, psf, image processing MATLAB Answers — New Questions
Calling PowerShell from MATLAB: executing commands from within script
My goal is to call PowerShell from MATLAB and set a file path from within the script that I am writing. I have as of now:
!PowerShell "Set-Location C:Program Files (x86)"
The error that is displayed is as follows:
x86 : The term ‘x86’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:32
+ Set-Location C:Program Files (x86)
+ ~~~
+ CategoryInfo : ObjectNotFound: (x86:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Note: !PowerShell works for me, and I can cd to the file path I want to go to in the command window. However, I want to set the file path in the script.My goal is to call PowerShell from MATLAB and set a file path from within the script that I am writing. I have as of now:
!PowerShell "Set-Location C:Program Files (x86)"
The error that is displayed is as follows:
x86 : The term ‘x86’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:32
+ Set-Location C:Program Files (x86)
+ ~~~
+ CategoryInfo : ObjectNotFound: (x86:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Note: !PowerShell works for me, and I can cd to the file path I want to go to in the command window. However, I want to set the file path in the script. My goal is to call PowerShell from MATLAB and set a file path from within the script that I am writing. I have as of now:
!PowerShell "Set-Location C:Program Files (x86)"
The error that is displayed is as follows:
x86 : The term ‘x86’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:32
+ Set-Location C:Program Files (x86)
+ ~~~
+ CategoryInfo : ObjectNotFound: (x86:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Note: !PowerShell works for me, and I can cd to the file path I want to go to in the command window. However, I want to set the file path in the script. matlab, powershell MATLAB Answers — New Questions
AM Transmitter/Receiver using Simulink
Is it possible to design a model for AM transmitter and AM receiver in Simulink?
If yes, then how?Is it possible to design a model for AM transmitter and AM receiver in Simulink?
If yes, then how? Is it possible to design a model for AM transmitter and AM receiver in Simulink?
If yes, then how? simulink, amplitude, modulation, am transmission, communication, radio MATLAB Answers — New Questions
Lowpass vs bandpass filtering
I’m having troubles using the lowpass filter. Here is the code I use.
Yacc=lowpass(Yacc,high,fs);
I set the filter to 100 Hz and looking at the power spectrum graph the filter doesn’t kick in until well over 2kHz.
I don’t have this problem using a bandpass filter. I use this code.
Yacc = bandpass(Yacc,[low high],fs);
Filtering from 10 to 100 Hz gives me this power spectrum graph.
Can someone explain what I’m doing wrongI’m having troubles using the lowpass filter. Here is the code I use.
Yacc=lowpass(Yacc,high,fs);
I set the filter to 100 Hz and looking at the power spectrum graph the filter doesn’t kick in until well over 2kHz.
I don’t have this problem using a bandpass filter. I use this code.
Yacc = bandpass(Yacc,[low high],fs);
Filtering from 10 to 100 Hz gives me this power spectrum graph.
Can someone explain what I’m doing wrong I’m having troubles using the lowpass filter. Here is the code I use.
Yacc=lowpass(Yacc,high,fs);
I set the filter to 100 Hz and looking at the power spectrum graph the filter doesn’t kick in until well over 2kHz.
I don’t have this problem using a bandpass filter. I use this code.
Yacc = bandpass(Yacc,[low high],fs);
Filtering from 10 to 100 Hz gives me this power spectrum graph.
Can someone explain what I’m doing wrong band pass filtering, low pass filtering MATLAB Answers — New Questions
Why do I receive the message, “Your installation may require additional configuration steps” after installing MathWorks products?
Why do I receive the message, "Your installation may require additional configuration steps" after installing MathWorks products?Why do I receive the message, "Your installation may require additional configuration steps" after installing MathWorks products? Why do I receive the message, "Your installation may require additional configuration steps" after installing MathWorks products? MATLAB Answers — New Questions
how to calculate median of grouped data in MATLAB
Given the two examples calculate the median in MATLAB using the function median
Example 1
Example 2
First example answer is 450 and the answer to the example 2 is 25.25Given the two examples calculate the median in MATLAB using the function median
Example 1
Example 2
First example answer is 450 and the answer to the example 2 is 25.25 Given the two examples calculate the median in MATLAB using the function median
Example 1
Example 2
First example answer is 450 and the answer to the example 2 is 25.25 median MATLAB Answers — New Questions
How to pass username and password to network location
Hi all,
I am trying to programatically access the network share under MATLAB dir command. It is working perfectly till the network is not password protected.
I am trying to pass the credentials as follows
dir(‘\servershare /user:test testpassword’)
but it gives me the "not found. Check the path or file permissions." error. I appreciate any hints.Hi all,
I am trying to programatically access the network share under MATLAB dir command. It is working perfectly till the network is not password protected.
I am trying to pass the credentials as follows
dir(‘\servershare /user:test testpassword’)
but it gives me the "not found. Check the path or file permissions." error. I appreciate any hints. Hi all,
I am trying to programatically access the network share under MATLAB dir command. It is working perfectly till the network is not password protected.
I am trying to pass the credentials as follows
dir(‘\servershare /user:test testpassword’)
but it gives me the "not found. Check the path or file permissions." error. I appreciate any hints. matlab, dir MATLAB Answers — New Questions
How to reset a stateflow state machine on external event?
Is it possible to re-initialize a state machine on an event generated by an other state machine?Is it possible to re-initialize a state machine on an event generated by an other state machine? Is it possible to re-initialize a state machine on an event generated by an other state machine? state machine MATLAB Answers — New Questions
Mathematical Equations to MATLAB
I am trying to implement a method for a reliability problem based on the following article main.pdf (sciencedirectassets.com). I am facing some problems while expressing the mathematical equations to MATLAB.
All required parameters are given as shown bellow.
lambda_i is given so that’s why I am expressing it bellow right after ‘%Equations’
Could you help me express the series of sum from (1 to N+1) of MTBFi from denominator, and the series of sum (from i to N) of the integral f(i)*(tau_i)*dtau_i from 0 to Xi?
Also, I don’t get when the lambda_i_plus_one is used on the CTM equation, any ideas?
%Parameters
beta = 2;alpha = 200;Ccl = 2000;Cpm = 2500;Rl = 1100;Cren = 50000;delta = 0.223;P = 12;N = 8; Clog = 1600;
%Equations
lambda_i = @(t) (beta / alpha) * (t / alpha).^(beta – 1); %It is given
lambda_i_plus_1 = @(t) exp(delta) * lambda_i(t);
f_i = @(t) lambda_i(t) .* exp(-integral(lambda_i(t), 0, t));
integral_MTBF = @(tau_i) tau_i .* f_i(tau_i); % This doesn’t work right
MTBF_i = integral(integral_MTBF, 0, Inf); % This doesn’t work right
Xi = MTBF + P; % MTBF should be a vector so that Xi will take values from 1 to N as article says.
%CTM
numerator=Rl*P*(sum_of_integrals)+(N*(Cpm+Ccl+Clog))+((Rl*P)+Ccl+Cren+Clog);
denominator=((N+1)*P)+(series_of_sum);
CTM=num/denI am trying to implement a method for a reliability problem based on the following article main.pdf (sciencedirectassets.com). I am facing some problems while expressing the mathematical equations to MATLAB.
All required parameters are given as shown bellow.
lambda_i is given so that’s why I am expressing it bellow right after ‘%Equations’
Could you help me express the series of sum from (1 to N+1) of MTBFi from denominator, and the series of sum (from i to N) of the integral f(i)*(tau_i)*dtau_i from 0 to Xi?
Also, I don’t get when the lambda_i_plus_one is used on the CTM equation, any ideas?
%Parameters
beta = 2;alpha = 200;Ccl = 2000;Cpm = 2500;Rl = 1100;Cren = 50000;delta = 0.223;P = 12;N = 8; Clog = 1600;
%Equations
lambda_i = @(t) (beta / alpha) * (t / alpha).^(beta – 1); %It is given
lambda_i_plus_1 = @(t) exp(delta) * lambda_i(t);
f_i = @(t) lambda_i(t) .* exp(-integral(lambda_i(t), 0, t));
integral_MTBF = @(tau_i) tau_i .* f_i(tau_i); % This doesn’t work right
MTBF_i = integral(integral_MTBF, 0, Inf); % This doesn’t work right
Xi = MTBF + P; % MTBF should be a vector so that Xi will take values from 1 to N as article says.
%CTM
numerator=Rl*P*(sum_of_integrals)+(N*(Cpm+Ccl+Clog))+((Rl*P)+Ccl+Cren+Clog);
denominator=((N+1)*P)+(series_of_sum);
CTM=num/den I am trying to implement a method for a reliability problem based on the following article main.pdf (sciencedirectassets.com). I am facing some problems while expressing the mathematical equations to MATLAB.
All required parameters are given as shown bellow.
lambda_i is given so that’s why I am expressing it bellow right after ‘%Equations’
Could you help me express the series of sum from (1 to N+1) of MTBFi from denominator, and the series of sum (from i to N) of the integral f(i)*(tau_i)*dtau_i from 0 to Xi?
Also, I don’t get when the lambda_i_plus_one is used on the CTM equation, any ideas?
%Parameters
beta = 2;alpha = 200;Ccl = 2000;Cpm = 2500;Rl = 1100;Cren = 50000;delta = 0.223;P = 12;N = 8; Clog = 1600;
%Equations
lambda_i = @(t) (beta / alpha) * (t / alpha).^(beta – 1); %It is given
lambda_i_plus_1 = @(t) exp(delta) * lambda_i(t);
f_i = @(t) lambda_i(t) .* exp(-integral(lambda_i(t), 0, t));
integral_MTBF = @(tau_i) tau_i .* f_i(tau_i); % This doesn’t work right
MTBF_i = integral(integral_MTBF, 0, Inf); % This doesn’t work right
Xi = MTBF + P; % MTBF should be a vector so that Xi will take values from 1 to N as article says.
%CTM
numerator=Rl*P*(sum_of_integrals)+(N*(Cpm+Ccl+Clog))+((Rl*P)+Ccl+Cren+Clog);
denominator=((N+1)*P)+(series_of_sum);
CTM=num/den mathematics, statistics, matlab function MATLAB Answers — New Questions
logspace with a different base
As far as I understood y = logspace(a,b,n) works for logarithms of base 10. For example we can have:
format longG
y = logspace(-2,3,6)
Is there a similar function or a simple way to perform the same calculation, but with a custom base B (for example a base B=3.5)?
I mean something like this:
a = -2;
b = 3;
n = 6;
B = 3.5;
y = …?As far as I understood y = logspace(a,b,n) works for logarithms of base 10. For example we can have:
format longG
y = logspace(-2,3,6)
Is there a similar function or a simple way to perform the same calculation, but with a custom base B (for example a base B=3.5)?
I mean something like this:
a = -2;
b = 3;
n = 6;
B = 3.5;
y = …? As far as I understood y = logspace(a,b,n) works for logarithms of base 10. For example we can have:
format longG
y = logspace(-2,3,6)
Is there a similar function or a simple way to perform the same calculation, but with a custom base B (for example a base B=3.5)?
I mean something like this:
a = -2;
b = 3;
n = 6;
B = 3.5;
y = …? logspace, logarithm, base MATLAB Answers — New Questions
Duplicate instances of methods executed while using parfeval and backgroundpool
I have the following function that sends regular updates
function countUp(q)
%countUp Counts up 1 every second
for i = 1:5
disp(i);
pause(1);
send(q, i);
end
end
The above function is called by the mlapp
properties (Access = private)
q = parallel.pool.DataQueue; % Description
L;
f;
end
methods (Access = private)
function myDisp(app, data)
log = [‘Recvd data update: ‘, num2str(data)];
disp(log);
app.Label.Text = num2str(data);
if(data == 5)
cancel(app.f);
app.StartButton.Enable = true;
end
end
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: StartButton
function StartButtonPushed(app, event)
disp(‘Start button clicked’);
app.StartButton.Enable = false;
app.L = afterEach(app.q, @(data) myDisp(app, data));
app.f = parfeval(backgroundPool,@countUp,0,app.q);
disp(‘Start button cb complete’);
end
% Button pushed function: StopButton
function StopButtonPushed(app, event)
delete(app.L);
cancel(app.f);
app.StartButton.Enable = true;
end
First run returns
Start button clicked
Start button cb complete
Recvd data update: 1
Recvd data update: 2
Recvd data update: 3
Recvd data update: 4
Recvd data update: 5
Each time I start it it looks like duplicate instances of the function is executed
Start button clicked
Start button cb complete
Recvd data update: 1
Recvd data update: 1
Recvd data update: 2
Recvd data update: 2
Recvd data update: 3
Recvd data update: 3
Recvd data update: 4
Recvd data update: 4
Recvd data update: 5
Recvd data update: 5
It never looks like cancel(Future) is working as intended. What am I doing wrong?I have the following function that sends regular updates
function countUp(q)
%countUp Counts up 1 every second
for i = 1:5
disp(i);
pause(1);
send(q, i);
end
end
The above function is called by the mlapp
properties (Access = private)
q = parallel.pool.DataQueue; % Description
L;
f;
end
methods (Access = private)
function myDisp(app, data)
log = [‘Recvd data update: ‘, num2str(data)];
disp(log);
app.Label.Text = num2str(data);
if(data == 5)
cancel(app.f);
app.StartButton.Enable = true;
end
end
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: StartButton
function StartButtonPushed(app, event)
disp(‘Start button clicked’);
app.StartButton.Enable = false;
app.L = afterEach(app.q, @(data) myDisp(app, data));
app.f = parfeval(backgroundPool,@countUp,0,app.q);
disp(‘Start button cb complete’);
end
% Button pushed function: StopButton
function StopButtonPushed(app, event)
delete(app.L);
cancel(app.f);
app.StartButton.Enable = true;
end
First run returns
Start button clicked
Start button cb complete
Recvd data update: 1
Recvd data update: 2
Recvd data update: 3
Recvd data update: 4
Recvd data update: 5
Each time I start it it looks like duplicate instances of the function is executed
Start button clicked
Start button cb complete
Recvd data update: 1
Recvd data update: 1
Recvd data update: 2
Recvd data update: 2
Recvd data update: 3
Recvd data update: 3
Recvd data update: 4
Recvd data update: 4
Recvd data update: 5
Recvd data update: 5
It never looks like cancel(Future) is working as intended. What am I doing wrong? I have the following function that sends regular updates
function countUp(q)
%countUp Counts up 1 every second
for i = 1:5
disp(i);
pause(1);
send(q, i);
end
end
The above function is called by the mlapp
properties (Access = private)
q = parallel.pool.DataQueue; % Description
L;
f;
end
methods (Access = private)
function myDisp(app, data)
log = [‘Recvd data update: ‘, num2str(data)];
disp(log);
app.Label.Text = num2str(data);
if(data == 5)
cancel(app.f);
app.StartButton.Enable = true;
end
end
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: StartButton
function StartButtonPushed(app, event)
disp(‘Start button clicked’);
app.StartButton.Enable = false;
app.L = afterEach(app.q, @(data) myDisp(app, data));
app.f = parfeval(backgroundPool,@countUp,0,app.q);
disp(‘Start button cb complete’);
end
% Button pushed function: StopButton
function StopButtonPushed(app, event)
delete(app.L);
cancel(app.f);
app.StartButton.Enable = true;
end
First run returns
Start button clicked
Start button cb complete
Recvd data update: 1
Recvd data update: 2
Recvd data update: 3
Recvd data update: 4
Recvd data update: 5
Each time I start it it looks like duplicate instances of the function is executed
Start button clicked
Start button cb complete
Recvd data update: 1
Recvd data update: 1
Recvd data update: 2
Recvd data update: 2
Recvd data update: 3
Recvd data update: 3
Recvd data update: 4
Recvd data update: 4
Recvd data update: 5
Recvd data update: 5
It never looks like cancel(Future) is working as intended. What am I doing wrong? parfeval, backgroundpool MATLAB Answers — New Questions
Deep learning numerical regression, no images, custom loss function
I want to define a neural network or deep learning. Firstly, I have [500 * 4] data with a sample size of 500, each with 4 features (x1, x2, x3, x4).
The output variables are y1 and y2 ([500 * 2]), but I don’t have any output data, I only have their range of values (such as y1 in range (0-1)).
I have the variable z, which is the measured data, z=5 * e ^ (y1)+7 * sin (y2)
The loss function will be defined as : z(measure) – z (y1, y2)
The purpose of this neural network is to estimate y1 and y2 based on x1, x2, x3, x4.
For instance:
I know information about 500 cats, which are: x1 (height), x2 (weight), x3 (food intake), x4 (excretion).
I also know the age of these 500 cats: z
Now, I want to estimate y1 (cancer probability) and y2 (hair loss). The range of y1 is 0-1, and the range of y2 is -10 to 10
Do you know how to establish such deep learning or neural networks? Is there a simple example?I want to define a neural network or deep learning. Firstly, I have [500 * 4] data with a sample size of 500, each with 4 features (x1, x2, x3, x4).
The output variables are y1 and y2 ([500 * 2]), but I don’t have any output data, I only have their range of values (such as y1 in range (0-1)).
I have the variable z, which is the measured data, z=5 * e ^ (y1)+7 * sin (y2)
The loss function will be defined as : z(measure) – z (y1, y2)
The purpose of this neural network is to estimate y1 and y2 based on x1, x2, x3, x4.
For instance:
I know information about 500 cats, which are: x1 (height), x2 (weight), x3 (food intake), x4 (excretion).
I also know the age of these 500 cats: z
Now, I want to estimate y1 (cancer probability) and y2 (hair loss). The range of y1 is 0-1, and the range of y2 is -10 to 10
Do you know how to establish such deep learning or neural networks? Is there a simple example? I want to define a neural network or deep learning. Firstly, I have [500 * 4] data with a sample size of 500, each with 4 features (x1, x2, x3, x4).
The output variables are y1 and y2 ([500 * 2]), but I don’t have any output data, I only have their range of values (such as y1 in range (0-1)).
I have the variable z, which is the measured data, z=5 * e ^ (y1)+7 * sin (y2)
The loss function will be defined as : z(measure) – z (y1, y2)
The purpose of this neural network is to estimate y1 and y2 based on x1, x2, x3, x4.
For instance:
I know information about 500 cats, which are: x1 (height), x2 (weight), x3 (food intake), x4 (excretion).
I also know the age of these 500 cats: z
Now, I want to estimate y1 (cancer probability) and y2 (hair loss). The range of y1 is 0-1, and the range of y2 is -10 to 10
Do you know how to establish such deep learning or neural networks? Is there a simple example? deep learning, loss function, regression MATLAB Answers — New Questions
Why is Dead Logic detected on my Switch block when using Design Verifier?
I believe that I am experiencing a false positive when running the mathworks.sldv.deadlogic check in the Model Advisor on Simulink. The model consists of a simple Switch block with an inport, outport, and two different Constant blocks input into the data ports.
The model:
The warning reads:
"RelationalOperator: input1 ~= input2 false"I believe that I am experiencing a false positive when running the mathworks.sldv.deadlogic check in the Model Advisor on Simulink. The model consists of a simple Switch block with an inport, outport, and two different Constant blocks input into the data ports.
The model:
The warning reads:
"RelationalOperator: input1 ~= input2 false" I believe that I am experiencing a false positive when running the mathworks.sldv.deadlogic check in the Model Advisor on Simulink. The model consists of a simple Switch block with an inport, outport, and two different Constant blocks input into the data ports.
The model:
The warning reads:
"RelationalOperator: input1 ~= input2 false" dead, logic, detection, switch, block, replacement MATLAB Answers — New Questions
How do I convert a Finite Integer to Hexadecimal in Simulink with Support for Code Generation?
There is no "dec2hex" block in Simulink, so how do you go about converting finite integers to hexadecimal representation in Simulink, with support for code generation?There is no "dec2hex" block in Simulink, so how do you go about converting finite integers to hexadecimal representation in Simulink, with support for code generation? There is no "dec2hex" block in Simulink, so how do you go about converting finite integers to hexadecimal representation in Simulink, with support for code generation? hexadecimal, dec2hex, simulink MATLAB Answers — New Questions
How do I prioritize Model Advisor check failures?
I want to resolve some Model Advisor checks first if they were to fail. How would I do that?I want to resolve some Model Advisor checks first if they were to fail. How would I do that? I want to resolve some Model Advisor checks first if they were to fail. How would I do that? model advisor MATLAB Answers — New Questions
Discrepancy between simscape and analytical solution
I am trying to simulate the behaviour of an electromechanical actuator, to model the BLDC I am using the block "Permanent Magnet
Synchronous Machine" with "Mechanical input" set into Mechanical rotational port.
The output of the block comprehends the rotor velocity in rad/s between the various informations.
I also connected the Mechanical rotational port to a set of gears modeled through simscape blocks (i’ll provide an image to clarify).
When I compute the actuation speed through a direct conversion of the motor velocity from rad/s to mm/s i obtain a value which is different from the one coming from the set of simscape gears.
In the picture the green line is the mechanical rotational port of the aforementioned block, while the series of gain is the simple conversion of the motor velocity from rad/s to mm/s
Am I using some of these blocks in the wrong way? It actually would seem to me a pretty straightforward application but apparently I’m missing something.
The gear ratio are all correct and so are the units of measure of the conversion blocks of the simscape section of the image.
At the moment I was using for the feedback control the velocity computed directly with the gains (black line) while I was using the green one only to apply the load to the motor, since otherwise I don’t see a way to model an external load, could this be a correct approach to the problem?
Thank you in advance, i will be extremly greatful to the ones who will answer, if you need more details feel free to ask me anything that could make the problem more clear to understand.I am trying to simulate the behaviour of an electromechanical actuator, to model the BLDC I am using the block "Permanent Magnet
Synchronous Machine" with "Mechanical input" set into Mechanical rotational port.
The output of the block comprehends the rotor velocity in rad/s between the various informations.
I also connected the Mechanical rotational port to a set of gears modeled through simscape blocks (i’ll provide an image to clarify).
When I compute the actuation speed through a direct conversion of the motor velocity from rad/s to mm/s i obtain a value which is different from the one coming from the set of simscape gears.
In the picture the green line is the mechanical rotational port of the aforementioned block, while the series of gain is the simple conversion of the motor velocity from rad/s to mm/s
Am I using some of these blocks in the wrong way? It actually would seem to me a pretty straightforward application but apparently I’m missing something.
The gear ratio are all correct and so are the units of measure of the conversion blocks of the simscape section of the image.
At the moment I was using for the feedback control the velocity computed directly with the gains (black line) while I was using the green one only to apply the load to the motor, since otherwise I don’t see a way to model an external load, could this be a correct approach to the problem?
Thank you in advance, i will be extremly greatful to the ones who will answer, if you need more details feel free to ask me anything that could make the problem more clear to understand. I am trying to simulate the behaviour of an electromechanical actuator, to model the BLDC I am using the block "Permanent Magnet
Synchronous Machine" with "Mechanical input" set into Mechanical rotational port.
The output of the block comprehends the rotor velocity in rad/s between the various informations.
I also connected the Mechanical rotational port to a set of gears modeled through simscape blocks (i’ll provide an image to clarify).
When I compute the actuation speed through a direct conversion of the motor velocity from rad/s to mm/s i obtain a value which is different from the one coming from the set of simscape gears.
In the picture the green line is the mechanical rotational port of the aforementioned block, while the series of gain is the simple conversion of the motor velocity from rad/s to mm/s
Am I using some of these blocks in the wrong way? It actually would seem to me a pretty straightforward application but apparently I’m missing something.
The gear ratio are all correct and so are the units of measure of the conversion blocks of the simscape section of the image.
At the moment I was using for the feedback control the velocity computed directly with the gains (black line) while I was using the green one only to apply the load to the motor, since otherwise I don’t see a way to model an external load, could this be a correct approach to the problem?
Thank you in advance, i will be extremly greatful to the ones who will answer, if you need more details feel free to ask me anything that could make the problem more clear to understand. simscape, simulink, synchronous machine MATLAB Answers — New Questions
rcsSignature RCS pattern change for radarTransceiver data generation
Hi!
I’m working with radarTransceiver object and I came across an issue, when I want to change the RCS of my target to achieve weaker signal nothing happens. I’ve tried different configurations of rcsSignature patterns, but nothing works, the signal is always with the same SNR.
Am I missing something?
Example code is in attachement with my RCS pattern modifications.
I want to achieve the smaller ampitude of the received signal reflected from taget 1.
Thank you for you help!Hi!
I’m working with radarTransceiver object and I came across an issue, when I want to change the RCS of my target to achieve weaker signal nothing happens. I’ve tried different configurations of rcsSignature patterns, but nothing works, the signal is always with the same SNR.
Am I missing something?
Example code is in attachement with my RCS pattern modifications.
I want to achieve the smaller ampitude of the received signal reflected from taget 1.
Thank you for you help! Hi!
I’m working with radarTransceiver object and I came across an issue, when I want to change the RCS of my target to achieve weaker signal nothing happens. I’ve tried different configurations of rcsSignature patterns, but nothing works, the signal is always with the same SNR.
Am I missing something?
Example code is in attachement with my RCS pattern modifications.
I want to achieve the smaller ampitude of the received signal reflected from taget 1.
Thank you for you help! radar, rcs, radartransceiver, rcssignature MATLAB Answers — New Questions
Output of irf() for VAR models when estimation data is in a matrix or a timetable
Hello,
I’m estimating a K-dimensional VAR model and looking at IRFs for structural (orthogonalized shocks) using the Econometrics toolbox, specifically varm(), estimate() and irf(). For orthogonalized shocks, the order of the model variables matters, as does the decomposition method. irf() uses the lower Cholesky decomposition (which is standard in econometrics), meaning that an orthogonalized shock to variable k will only have a contemporaneous effect on variables k, …, K, but not variables 1, …, k-1.
When estimating the model, I can use an array or a (time)table for my observed data, and the output of irf() will then also be an array or (time)table respectively. My question concerns the interpretation of the entries of either return value, specifically which IRFs are found where in the data structures returned. I am finding difficult to make sense of the documentation, and I’m now thinking that the documentation for irf() (alternatively, its code) is wrong for the timetable case.
Here’s a code snippet, based on the Danish data example in the documentation, that will illustrate what I mean. The order of variables in this model is M2, Y, IB, ID, meaning that (say) a shock to Y should influence IB and ID contemporaneously but not M2.
load Data_JDanish
Mdl = varm(4, 2);
Mdl.SeriesNames = DataTable.Properties.VariableNames;
EstMdlMat = estimate(Mdl, Data);
rng(1);
ResponseMat = irf(EstMdlMat);
% "Display the IRF of the bond rate (variable 3, IB) when the log of real
% income (variable 2, Y) is shocked at time 0."
ResponseMat(:, 2, 3).’
EstMdlTab = estimate(Mdl, DataTimeTable);
rng(1);
ResponseTab = irf(EstMdlTab);
% "For example, Tbl.M2_IRF(:,2) is the IRF of M2 resulting from a
% one-standard-deviation shock on 01-Jul-1974 (period 0) to
% Mdl.SeriesNames(2), which is the variable Y."
ResponseTab.IB_IRF(:, 2).’
Here, ReponseMat(:, 2, 3) is (as indicated by the quote in the comment, which is copied verbatim from the documentation page) the IRF of IB after an orthogonalized shock to Y. When estimating the model using data in a timetable, then (as indicated by the second quote, which is also from the documentation), ResponseTab.IB_IRF(:, 2) should be the IRF of IB after an orthogonalized shock to Y, and hence be identical to ResponseMat(:, 2, 3) (possibly up to round-off error).
Except it isn’t. In fact, the first element of ResponseTab.IB_IRF(:, 2) is zero. This suggests to me that when using irf() with data in a timetable, the economic ordering of the variables should be the opposite. This would result if irf() was using the upper Cholesky decomposition in this case.
But there’s no good reason why it should do that. In fact, there is no good reason why the two methods should give different results at all. The easiest explanation (excluding silly mistakes on my part) is that the documentation for the timetable case is wrong, and ResponseTab.IB_IRF(:, 2) should be read as the IRF of variable 2 (Y) after a shock to IB.
Would be nice if someone could shed some light on this.
For the record: I’m using MATLAB R2024a Update 4, the latest version.Hello,
I’m estimating a K-dimensional VAR model and looking at IRFs for structural (orthogonalized shocks) using the Econometrics toolbox, specifically varm(), estimate() and irf(). For orthogonalized shocks, the order of the model variables matters, as does the decomposition method. irf() uses the lower Cholesky decomposition (which is standard in econometrics), meaning that an orthogonalized shock to variable k will only have a contemporaneous effect on variables k, …, K, but not variables 1, …, k-1.
When estimating the model, I can use an array or a (time)table for my observed data, and the output of irf() will then also be an array or (time)table respectively. My question concerns the interpretation of the entries of either return value, specifically which IRFs are found where in the data structures returned. I am finding difficult to make sense of the documentation, and I’m now thinking that the documentation for irf() (alternatively, its code) is wrong for the timetable case.
Here’s a code snippet, based on the Danish data example in the documentation, that will illustrate what I mean. The order of variables in this model is M2, Y, IB, ID, meaning that (say) a shock to Y should influence IB and ID contemporaneously but not M2.
load Data_JDanish
Mdl = varm(4, 2);
Mdl.SeriesNames = DataTable.Properties.VariableNames;
EstMdlMat = estimate(Mdl, Data);
rng(1);
ResponseMat = irf(EstMdlMat);
% "Display the IRF of the bond rate (variable 3, IB) when the log of real
% income (variable 2, Y) is shocked at time 0."
ResponseMat(:, 2, 3).’
EstMdlTab = estimate(Mdl, DataTimeTable);
rng(1);
ResponseTab = irf(EstMdlTab);
% "For example, Tbl.M2_IRF(:,2) is the IRF of M2 resulting from a
% one-standard-deviation shock on 01-Jul-1974 (period 0) to
% Mdl.SeriesNames(2), which is the variable Y."
ResponseTab.IB_IRF(:, 2).’
Here, ReponseMat(:, 2, 3) is (as indicated by the quote in the comment, which is copied verbatim from the documentation page) the IRF of IB after an orthogonalized shock to Y. When estimating the model using data in a timetable, then (as indicated by the second quote, which is also from the documentation), ResponseTab.IB_IRF(:, 2) should be the IRF of IB after an orthogonalized shock to Y, and hence be identical to ResponseMat(:, 2, 3) (possibly up to round-off error).
Except it isn’t. In fact, the first element of ResponseTab.IB_IRF(:, 2) is zero. This suggests to me that when using irf() with data in a timetable, the economic ordering of the variables should be the opposite. This would result if irf() was using the upper Cholesky decomposition in this case.
But there’s no good reason why it should do that. In fact, there is no good reason why the two methods should give different results at all. The easiest explanation (excluding silly mistakes on my part) is that the documentation for the timetable case is wrong, and ResponseTab.IB_IRF(:, 2) should be read as the IRF of variable 2 (Y) after a shock to IB.
Would be nice if someone could shed some light on this.
For the record: I’m using MATLAB R2024a Update 4, the latest version. Hello,
I’m estimating a K-dimensional VAR model and looking at IRFs for structural (orthogonalized shocks) using the Econometrics toolbox, specifically varm(), estimate() and irf(). For orthogonalized shocks, the order of the model variables matters, as does the decomposition method. irf() uses the lower Cholesky decomposition (which is standard in econometrics), meaning that an orthogonalized shock to variable k will only have a contemporaneous effect on variables k, …, K, but not variables 1, …, k-1.
When estimating the model, I can use an array or a (time)table for my observed data, and the output of irf() will then also be an array or (time)table respectively. My question concerns the interpretation of the entries of either return value, specifically which IRFs are found where in the data structures returned. I am finding difficult to make sense of the documentation, and I’m now thinking that the documentation for irf() (alternatively, its code) is wrong for the timetable case.
Here’s a code snippet, based on the Danish data example in the documentation, that will illustrate what I mean. The order of variables in this model is M2, Y, IB, ID, meaning that (say) a shock to Y should influence IB and ID contemporaneously but not M2.
load Data_JDanish
Mdl = varm(4, 2);
Mdl.SeriesNames = DataTable.Properties.VariableNames;
EstMdlMat = estimate(Mdl, Data);
rng(1);
ResponseMat = irf(EstMdlMat);
% "Display the IRF of the bond rate (variable 3, IB) when the log of real
% income (variable 2, Y) is shocked at time 0."
ResponseMat(:, 2, 3).’
EstMdlTab = estimate(Mdl, DataTimeTable);
rng(1);
ResponseTab = irf(EstMdlTab);
% "For example, Tbl.M2_IRF(:,2) is the IRF of M2 resulting from a
% one-standard-deviation shock on 01-Jul-1974 (period 0) to
% Mdl.SeriesNames(2), which is the variable Y."
ResponseTab.IB_IRF(:, 2).’
Here, ReponseMat(:, 2, 3) is (as indicated by the quote in the comment, which is copied verbatim from the documentation page) the IRF of IB after an orthogonalized shock to Y. When estimating the model using data in a timetable, then (as indicated by the second quote, which is also from the documentation), ResponseTab.IB_IRF(:, 2) should be the IRF of IB after an orthogonalized shock to Y, and hence be identical to ResponseMat(:, 2, 3) (possibly up to round-off error).
Except it isn’t. In fact, the first element of ResponseTab.IB_IRF(:, 2) is zero. This suggests to me that when using irf() with data in a timetable, the economic ordering of the variables should be the opposite. This would result if irf() was using the upper Cholesky decomposition in this case.
But there’s no good reason why it should do that. In fact, there is no good reason why the two methods should give different results at all. The easiest explanation (excluding silly mistakes on my part) is that the documentation for the timetable case is wrong, and ResponseTab.IB_IRF(:, 2) should be read as the IRF of variable 2 (Y) after a shock to IB.
Would be nice if someone could shed some light on this.
For the record: I’m using MATLAB R2024a Update 4, the latest version. irf, econometrics, var model, varm, econometrics toolbox, cholesky decomposition, variable ordering, irfs MATLAB Answers — New Questions
What is the meaning of the variables in the C generated code of a Linear Discriminant Analysis model trained in MATLAB?
I have trained a Linear Discriminant Analysis model in MATLAB, and I have generated the corresponding C code:
void myLDApredic(const double X[8], cell_wrap_0 label[1],double score[5])
{
static const double dv[8] = {22.242777113313874, 10091.972043688236,
18.120065167575063, 1.6703515441084688E+6,
24.467860977243351, 10578.886659888578,
19.515843697095619, 1.9037831242647208E+6};
static const double dv1[5] = {0.19444444444444445, 0.19791666666666666,
0.20254629629629631, 0.18865740740740741,
0.21643518518518517};
// rest of function body…
}
void DiagonalDiscriminant(const double X[8], double mah[5])
{
static const double dv[40] = {
92.058756510416757, 428.55436769005888, 99.445223214285761,
121.16319976993877, 28.000396891711258, 12736.000000000013,
81355.60233918138, 19612.525714285723, 16993.374233128856,
3436.1497326203244, 143.11044456845252, 72.791255482456208,
144.52926339285719, 196.37662960122714, 29.916151403743349,
5.2292266666666726E+6, 3.3097596257309979E+6, 7.8175085714285746E+6,
7.0232076564417249E+6, 894724.10695187247, 480.39411272321479,
26.045367324561425, 53.19522321428574, 239.98229006901863,
20.971883355614992, 80371.8095238096, 2976.1871345029267,
8478.720000000003, 52414.036809816, 2602.4385026737991,
325.64160156250028, 34.383543494152079, 84.338125000000034,
72.35264091257676, 33.127548462566885, 1.6916089904761918E+7,
1.5491024093567266E+6, 3.7583959771428583E+6, 4.3856852024539923E+6,
1.6065081497326223E+6};
static const double dv1[8] = {0.044958414810596169, 9.9088661331104676E-5,
0.0551874394905295, 5.9867637056829179E-7,
0.040869939588510124, 9.4527905643572937E-5,
0.051240418580971815, 5.2526991507303129E-7};
// rest of function body…
}
What is the meaning of the variables "dv", "dv1" of files "myLDApredict" and "DiagonalDiscriminant"?I have trained a Linear Discriminant Analysis model in MATLAB, and I have generated the corresponding C code:
void myLDApredic(const double X[8], cell_wrap_0 label[1],double score[5])
{
static const double dv[8] = {22.242777113313874, 10091.972043688236,
18.120065167575063, 1.6703515441084688E+6,
24.467860977243351, 10578.886659888578,
19.515843697095619, 1.9037831242647208E+6};
static const double dv1[5] = {0.19444444444444445, 0.19791666666666666,
0.20254629629629631, 0.18865740740740741,
0.21643518518518517};
// rest of function body…
}
void DiagonalDiscriminant(const double X[8], double mah[5])
{
static const double dv[40] = {
92.058756510416757, 428.55436769005888, 99.445223214285761,
121.16319976993877, 28.000396891711258, 12736.000000000013,
81355.60233918138, 19612.525714285723, 16993.374233128856,
3436.1497326203244, 143.11044456845252, 72.791255482456208,
144.52926339285719, 196.37662960122714, 29.916151403743349,
5.2292266666666726E+6, 3.3097596257309979E+6, 7.8175085714285746E+6,
7.0232076564417249E+6, 894724.10695187247, 480.39411272321479,
26.045367324561425, 53.19522321428574, 239.98229006901863,
20.971883355614992, 80371.8095238096, 2976.1871345029267,
8478.720000000003, 52414.036809816, 2602.4385026737991,
325.64160156250028, 34.383543494152079, 84.338125000000034,
72.35264091257676, 33.127548462566885, 1.6916089904761918E+7,
1.5491024093567266E+6, 3.7583959771428583E+6, 4.3856852024539923E+6,
1.6065081497326223E+6};
static const double dv1[8] = {0.044958414810596169, 9.9088661331104676E-5,
0.0551874394905295, 5.9867637056829179E-7,
0.040869939588510124, 9.4527905643572937E-5,
0.051240418580971815, 5.2526991507303129E-7};
// rest of function body…
}
What is the meaning of the variables "dv", "dv1" of files "myLDApredict" and "DiagonalDiscriminant"? I have trained a Linear Discriminant Analysis model in MATLAB, and I have generated the corresponding C code:
void myLDApredic(const double X[8], cell_wrap_0 label[1],double score[5])
{
static const double dv[8] = {22.242777113313874, 10091.972043688236,
18.120065167575063, 1.6703515441084688E+6,
24.467860977243351, 10578.886659888578,
19.515843697095619, 1.9037831242647208E+6};
static const double dv1[5] = {0.19444444444444445, 0.19791666666666666,
0.20254629629629631, 0.18865740740740741,
0.21643518518518517};
// rest of function body…
}
void DiagonalDiscriminant(const double X[8], double mah[5])
{
static const double dv[40] = {
92.058756510416757, 428.55436769005888, 99.445223214285761,
121.16319976993877, 28.000396891711258, 12736.000000000013,
81355.60233918138, 19612.525714285723, 16993.374233128856,
3436.1497326203244, 143.11044456845252, 72.791255482456208,
144.52926339285719, 196.37662960122714, 29.916151403743349,
5.2292266666666726E+6, 3.3097596257309979E+6, 7.8175085714285746E+6,
7.0232076564417249E+6, 894724.10695187247, 480.39411272321479,
26.045367324561425, 53.19522321428574, 239.98229006901863,
20.971883355614992, 80371.8095238096, 2976.1871345029267,
8478.720000000003, 52414.036809816, 2602.4385026737991,
325.64160156250028, 34.383543494152079, 84.338125000000034,
72.35264091257676, 33.127548462566885, 1.6916089904761918E+7,
1.5491024093567266E+6, 3.7583959771428583E+6, 4.3856852024539923E+6,
1.6065081497326223E+6};
static const double dv1[8] = {0.044958414810596169, 9.9088661331104676E-5,
0.0551874394905295, 5.9867637056829179E-7,
0.040869939588510124, 9.4527905643572937E-5,
0.051240418580971815, 5.2526991507303129E-7};
// rest of function body…
}
What is the meaning of the variables "dv", "dv1" of files "myLDApredict" and "DiagonalDiscriminant"? c, code, lineardiscriminantanalysis, variables, meaning MATLAB Answers — New Questions