조회 수: 13(최근 30일)
Stephen Bell 2021년 8월 12일
답변: Bhuvanyu Dogra 2021년 8월 16일
clear all
close all
clc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%the equation put in Fcn (block)is (-m*g-sgn(u*A*rho*u^2)/m in simulink
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%The rest of the code I can work out myself. I need a substitution for Fcn block please.
g=9.81
d=0.1;
rhoMaterial =100;
R=.287 % gas constant for air kj/kg;
p=101.325 % barometric pressure
t=20; % temperture
rhoAir =p/(R*(273+t));%
A=pi*d.^2/4;
m=rhoMaterial*1/6*pi*d.^3
Cd=0.6;%0.6;
theta=40' %54 %boomerang
v=40;
xdot0 =v*cos(theta*pi/180);
ydot0=v*cos(theta*pi/180);
x0=0;
y0=0;
wx=-10; %-10
wy=0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% call the Simulink model. Results(states)returned to Workspace in xout
sim('traject');
%plot(xout(:,1),xout(:2))
quiver(xout(:,1),xout(:,2),xout(:,3),xout(:,4))
axis equal
hold on
plot(xout(end,1),xout(end,2),'ro')
xlabel('x [m]')
ylabel('y [m]')
title(sprintf('v=%.2fm/s, \\theta=%.1f^o',v,theta))
grid on

댓글을 달려면 로그인하십시오.

채택된 답변

Bhuvanyu Dogra 2021년 8월 16일
It is my understanding that you are looking for an alternative to the 'Fcn' block in the R2021a release.
The following documentation suggests the use of 'MATLAB Function' block instead of the 'Fcn' block in the R2021a release:
Please refer to the MATLAB Function Block documentation for more information on the usage of the block.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!