Source function f in pde toobox
1 view (last 30 days)
Show older comments
It appears that a function to represent a source f = fcoefficient(location,state) does not allow for complex inputs. I want to couple equations where the source for one of the components is a complex quantity; e.g., f(4,:) is a function of solutions of the other components. These solutions are complex.
0 Comments
Answers (1)
Anurag Ojha
on 7 May 2024
Hello Lewis
In MATLAB, you can work with complex numbers and perform operations on them. If you want to represent a complex source function, you can define it as a function handle that takes complex inputs.
Adding a sample code for your reference
% Define the source function
f = @(location, state) complexFunction(location, state);
% Define the complex function
function result = complexFunction(location, state)
% Perform operations on complex inputs
result = state(1,:) + 1i*state(2,:);
end
In the code above, the "complexFunction" takes two inputs "location" and "state", where "state" is a matrix of complex solutions for other components. The function performs operations on the complex inputs and returns a complex result.
0 Comments
See Also
Categories
Find more on Boundary Conditions 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!