Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

call with matlabfunction(simulink) an other mfile

조회 수: 3 (최근 30일)
sia
sia 2013년 6월 3일
마감: MATLAB Answer Bot 2021년 8월 20일
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

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 6월 3일
  댓글 수: 9
sia
sia 2013년 6월 3일
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 2013년 6월 3일
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)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by