Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

call with matlabfunction(simulink) an other mfile

3 visualizaciones (últimos 30 días)
sia
sia el 3 de Jun. de 2013
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
Hi, i have a simulink model, which computes a value, then i give this value to a matlab funktion, then fron this matlab funktion i wanna call an other mfile funktion and give this mfile function this value.
How can i call an other funktion and give a value???? THX

Respuestas (1)

Azzi Abdelmalek
Azzi Abdelmalek el 3 de Jun. de 2013
  9 comentarios
sia
sia el 3 de Jun. de 2013
they are constants for building a geimetry. i = [x y z] d = [dx dy dz] voxlesize c = color
I added my function into the matlabfunction, looks like this
function y = handle (u)
y = test_environment(u);
function y = test_environment(u)
switch(nargin),
case 0
i = [5 5 5];
d= [1 1 1];
c= 'b';
alpha = 0.5;
case 1
l=1; %default length of side of voxel is 1
c='b'; %default color of voxel is blue
case 2,
c='b';
case 3,
alpha=1;
case 4,
%do nothing
otherwise
disp('Too many arguements for voxel');
end;
x=[i(1)+[0 0 0 0 d(1) d(1) d(1) d(1)]; ...
i(2)+[0 0 d(2) d(2) 0 0 d(2) d(2)]; ...
i(3)+[0 d(3) 0 d(3) 0 d(3) 0 d(3)]]';
for n=1:3,
if n==3,
x=sortrows(x,[n,1]);
else
x=sortrows(x,[n n+1]);
end;
temp=x(3,:);
x(3,:)=x(4,:);
x(4,:)=temp;
h=patch(x(1:4,1),x(1:4,2),x(1:4,3),c);
set(h,'FaceAlpha',alpha);
temp=x(7,:);
x(7,:)=x(8,:);
x(8,:)=temp;
h=patch(x(5:8,1),x(5:8,2),x(5:8,3),c);
set(h,'FaceAlpha',alpha);
%WeltkoordinatenSystem
axis([0,10,0,10,0,10])
xlabel('X-Achse')
ylabel('Y-Achse')
zlabel('Z-Achse')
grid on
hold off
end;
end
Azzi Abdelmalek
Azzi Abdelmalek el 3 de Jun. de 2013
You do not need to put the m-file in your Matlab fcn block, you have just to call the function in the block Matlab fcn. but you need to use i,d,c,alpha as constants or signals
function y = load_handles(i,d,c,alpha)
%#codegen
y = test_environment(i,d,c,alpha)

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by