Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

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

1 Ansicht (letzte 30 Tage)
JoshT_student
JoshT_student am 14 Jun. 2018
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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 Kommentare
Stephen23
Stephen23 am 14 Jun. 2018
Bearbeitet: Stephen23 am 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 am 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

Antworten (0)

Diese Frage ist geschlossen.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by