Borrar filtros
Borrar filtros

dot indexing in a function handle

4 visualizaciones (últimos 30 días)
Geovane Gomes
Geovane Gomes el 10 de Mzo. de 2023
Comentada: Rik el 10 de Mzo. de 2023
Hi all,
Is it possible to use dot indexing in a function handle? Or at least ignore an output?
Please look at the code below.
clear
clc
close
format shortG
P = 100;
vel = 1.5066e+03;
omegab = 0;
L = 30480;
E = 200000;
I = 1.6253e6;
b = 2438;
h = 20;
A = b * h;
rho = 7.8E-9;
jmax = 5;
varMean = [P vel];
varStd = abs([0.15 0.15] .* varMean);
varDist = ["normal","normal"];
g = @(X) 1.76 - beamUnderMovingLoad(X(1),X(2),L,E,I,omegab,rho,A,jmax);
inputs = struct('means', varMean, 'stds', varStd, 'dists', varDist, 'g_func', g, 'N', 10000);
output = monteCarloSimulation(inputs)
output.Pf
output.Beta
It runs properly when the function 'beamUnderMovingLoad()' has only one output, but Id like to select the output in the 'g' function.
Trust all clear!

Respuesta aceptada

Rik
Rik el 10 de Mzo. de 2023
Editada: Rik el 10 de Mzo. de 2023
You will have to write a wrapper that can select an output for you. There is no built-in functionality to do so.
Some like this should work:
function out=output_selector(fun,k,varargin)
% Select the k-th output variable given some input.
% The first input should be a function handle. Any inputs required for the
% function can provided as extra arguments.
out = cell(1,k);
[out{:}]=fun(varargin{:});
out = out{end};
end
  8 comentarios
Geovane Gomes
Geovane Gomes el 10 de Mzo. de 2023
Wow!!!
Now it works perfect!
i really appreciate your help
Rik
Rik el 10 de Mzo. de 2023
You're welcome

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by