Info

This question is closed. Reopen it to edit or answer.

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

1 view (last 30 days)
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 Comments
Stephen23
Stephen23 on 14 Jun 2018
Edited: Stephen23 on 14 Jun 2018
"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 on 14 Jun 2018
It also seems you are missing the dot before ^ for your matrix math.
exp_numerator= -(a).*((delta).^2).*t ; %This just simplifies things
^
|
Here

Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!