not enough input arg
1 view (last 30 days)
Show older comments
tier el
on 26 Nov 2015
Commented: Walter Roberson
on 26 Nov 2015
%function definition
function [eco1, eco2, ag2, eco3, ag3, eco4, ag4, eco5, ag5, eco6, eco7, P] = fcn (TX, TY, TZ, RX, RY, RZ, CX, CY, CZ)
% D1 = sqrt((x2-x1)^2 + (y2-y1)^2 + (z2-z1)^2)
%%Rxc2 = [2*w-x2, y2, z2]
% D2 = sqrt(((2*w-x2)-x1)^2 + (y2-y1)^2 + (z2-z1)^2)
%%Rxc3 = [-x2, y2, z2]
% D3 = ((-x2-x1)^2 + (y2-y1)^2 + (z2-z1)^2)
%%Rxc4 = [x2, y2, 2*D-z2]
% D4= sqrt((x2-x1)^2 + (y2-y1)^2 + ((2*D-z2)-z1)^2)
%%Rxc5 = [x2, y2, -z2]
% D5 = sqrt((x2-x1)^2 + (y2-y1)^2 + (-z2-z1)^2)
% Case z1==z2, i.e. at the same level the echoes are the same
%%Rxc6 = [x2, -y2, z2]
% D4 = sqrt((x2-x1)^2 + (-y2-y1)^2 + (z2-z1)^2)
%%Rxc7 = [x2, 2*L-y2, z2]
% D5 = sqrt((x2-x1)^2 + ((2*L-y2)-y1)^2 + (z2-z1)^2)
% result signal
eco1 = sqrt((RX-TX)^2 + (RY-TY)^2 + (RZ-TZ^2));
eco2 = sqrt(((2*CX-RX)-TX)^2 + (RY-TY)^2 + (RZ-TZ)^2);
ag2 = asin(abs((2*CX-RX)-TX)/eco2);
eco3 = sqrt((-RX-TX)^2 + (RY-TY)^2 + (RZ-TZ)^2);
ag3 = asin((RX+TX)/eco3);
eco4 = sqrt((RX-TX)^2 + (RY-TY)^2 + (-RZ-TZ)^2);
ag4 = asin(abs((2*CZ-RZ)-TZ)/eco4);
eco5 = sqrt((RX-TX)^2 + (RY-TY)^2 + (-RZ-TZ)^2);
ag5 = asin((RZ+TZ)/eco5);
if ((RZ==TZ) && (RX==TX))
eco6 = (RY+TY);
eco7 = sqrt(((2*CY-RY)-TY)^2);
else
eco6 = 0;
eco7 = 0;
end
P=(RZ+TZ)/2;
8 Comments
Stephen23
on 26 Nov 2015
Edited: Stephen23
on 26 Nov 2015
Walter Roberson has already told you how, see their Answer.
You cannot run a function that requires input arguments by simply clicking on that toolbar button. It is easiest to call the function from the command window (or from another function or script), together with all of its required input arguments.
Accepted Answer
Walter Roberson
on 26 Nov 2015
Your first non-comment line is
function [eco1, eco2, ag2, eco3, ag3, eco4, ag4, eco5, ag5, eco6, eco7, P] = fcn (TX, TY, TZ, RX, RY, RZ, CX, CY, CZ)
This declares a function named "fcn". You need to store that in a file named fcn.m
When you run the function from the command prompt, you need to provide parameters to run it with. For example,
>> fcn(rand(), rand(), rand(), rand(), rand(), rand(), rand(), rand(), rand())
3 Comments
Walter Roberson
on 26 Nov 2015
I took your code unchanged:
>> fcn(rand(), rand(), rand(), rand(), rand(), rand(), rand(), rand(), rand())
ans =
0.40732350841585
Your code is designed to handle only scalar inputs. If you are trying to pass in vector or matrix inputs then you will need to change all of your ^ to .^ and all of your / to ./ but more importantly you would need to re-code your "if" because it is designed only for scalar values.
More Answers (0)
See Also
Categories
Find more on Environment and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!