Clear Filters
Clear Filters

Invalid indexing or function definition of curl function

1 view (last 30 days)
The code used to work before but now is showing invalid indexing or function difinition
%<curl> <divergence> <gradient>
syms q w e r t y u i o p l k j h g f d s a z x c v b n m
fprintf('\n <curl> <divergence> <gradient>')
fprintf('\n *********************************')
fprintf('\n vector field -> 1 Scalor-> 0')
V=[x y z];
Q0= input("\n do you want to operate on a vector field or a Scalor : ");
if Q0==1
Vector1x = input ('\n input the X component of your vector : ');
Vector1y = input ('\n input the y component of your vector : ');
Vector1z = input ('\n input the z component of your vector : ');
v1=[Vector1x,Vector1y,Vector1z];
fprintf('Divergence -> 1 curl-> 0')
Q1=input("\n do you want to compute curl or divergence : ");
if Q1==1
V=[x y z];
Vd=[Vector1x,Vector1y,Vector1z];
div=divergence(Vd,V)
else
V=[x y z];
Vc=[Vector1x,Vector1y,Vector1z];
Curl=curl(Vc,V)
end
else
scaler = input( "\n write your scalor function\ : " );
fun=scaler
grad=gradient(fun,V)
end
Erorrs
Error using sym/subsindex
Invalid indexing or function definition. Indexing must follow
MATLAB indexing. Function arguments must be symbolic variables,
and function body must be sym expression.
Error in indexing (line 1079)
R_tilde = builtin('subsref',L_tilde,Idx);
Error in CDG (line 24)
Curl=curl(Vc,V)
  1 Comment
Rik
Rik on 15 Nov 2022
Please format your code as code. That will allow you to run it within this forum. When you attempt to run it, you will notice that you have several manual inputs, which you did not describe. Please supply example inputs that you expect to work.

Sign in to comment.

Answers (0)

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!