Info

此问题已关闭。 请重新打开它进行编辑或回答。

Is there any way I can put a matrix in my defined function

1 次查看(过去 30 天)
Hello everybody,
This is my defined function:
%This function is for number 2 of project 4.1
%I will use this function to define TRATIO.
function tratio_sol=my_TRATIO(delta, t, x_over_L)
global a L ;
a=0.279e-5; %This is in meters squared per second
L=0.03; %this is in meters
L_squared=L*L; %This just simplifies things
exp_numerator= -(a).*((delta)^2).*t ; %This just simplifies things
inside=(delta).*(x_over_L); %This just simplifies things
numerator_part=(sin(delta)).*(cos(inside)); %This just simplifies things
denominator= cos(delta).*sin(delta) + delta; %This just simplifies things
top=(exp_numerator)./(L-squared); %This just simplifies things
numer_f= numerator_part.*exp(top); %This just simplifies things
tratio_sol= 2*(numer_f./denominator); %This just simplifies things
%THIS COMPLETES MY FUNCTION
Is there any way I can put a matrix for 'delta'? Or no?
  2 个评论
Stephen23
Stephen23 2018-6-14
编辑:Stephen23 2018-6-14
"Is there any way I can put a matrix in my defined function"
Of course, if you write your function to accept a matrix, then it can accept a matrix as an input. As your code contains no explanation of what it is supposed to be doing, you have not explained anything about the algorithm, and you have not explained what you tried or what you expect to get, we have no idea if your code does (or can do) what you want.
Please edit your question and clarify what you are actually trying to achieve.
Michael Horn
Michael Horn 2018-6-14
It also seems you are missing the dot before ^ for your matrix math.
exp_numerator= -(a).*((delta).^2).*t ; %This just simplifies things
^
|
Here

回答(0 个)

此问题已关闭。

产品

Community Treasure Hunt

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

Start Hunting!

Translated by