how can i overcome this error

CCT(2,3,2,3)
sum =
0
0
Error in RCT3 (line 2)
syms t r theta phi p(r) q(r) a
Output argument "R" (and maybe others) not
assigned during call to "C:\Users\Shiraz
Khan\Documents\MATLAB\RCT3.m>RCT3".
Error in CCT (line 13)
sum=sum+g(i,m)*RCT3(j,k,l,m);

2 Comments

shiraz - can you share the code for RCT3.m? Given the error message, the R output parameter is not being set given your inputs.
Shiraz's answer moved here
function [R]= RCT3(i,j,k,m)
syms t r theta phi p(r) q(r) a
g=[exp(p(r)) 0 0 0; 0 -exp(q(r)) 0 0; 0 0 -r^2 0; 0 0 0 -r^2*(sin(theta))^2];
x= [t r theta phi];
A=diff(SRH2(i,k,m),x(1,j));
% pretty(A)
B=diff(SRH2(i,j,m),x(1,k));
% pretty(B);
sum1=0;
for n=1:4
sum1=sum1+SRH2(i,k,n)*SRH2(n,j,m);
end
sum1;
% pretty(sum1)
sum2=0;
for n=1:4
sum2=sum2+SRH2(i,j,n)*SRH2(n,k,m);
end
sum2;
% pretty(sum2)
sum=A-B+sum1-sum2;
sum;
pretty(sum)
end

Sign in to comment.

 Accepted Answer

Shiraz - your function signature is
function [R]= RCT3(i,j,k,m)
which means that the output parameter from your function is named R and so you must initialize a local variable (within your code) with that same name. If you don't do this, then you will get the Output argument "R" (and maybe others) not assigned during call.
Perhaps this is the sum local variable in your code? If it is, then rename it to R. If it isn't, then rename it anyway since it will conflict with the MATLAB built-in function sum.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!