Filter löschen
Filter löschen

Plotting implicit functions via fimplicit

4 Ansichten (letzte 30 Tage)
Michael Haag
Michael Haag am 20 Sep. 2023
Bearbeitet: Voss am 20 Sep. 2023
Hello,
I have the following anonymous function:
L = 5000;
F = 11500;
E = 70000;
cP = @(B,H)[H.*(B.^-1)-6, 6.*F.*L.*((B.*H.^2).^-1)-50,...
4.*F.*L.^3.*((E.*B.*H.^3).^-1)-12.7];
Now I want to plot each curve in the vector via
interval = [0 500 0 500];
fimplicit(cP,interval);
This does not work. I suppose fimplicit expects only one curve and could not handle the vector containig the curves.
So, how can I access the each curve, i.e H.*(B.^-1)-6=0, which are in the vector and pass it to fimplicit so that fimplicit can handle it?
Thanks in advance,
Michael

Akzeptierte Antwort

Voss
Voss am 20 Sep. 2023
Apparently (this behavior appears to be undocumented), you can pass a cell array of function handles to fimplicit, as in:
L = 5000;
F = 11500;
E = 70000;
interval = [0 500 0 500];
% cP = @(B,H)[H.*(B.^-1)-6, 6.*F.*L.*((B.*H.^2).^-1)-50,...
% 4.*F.*L.^3.*((E.*B.*H.^3).^-1)-12.7];
cP = { ...
@(B,H)H.*(B.^-1)-6, ...
@(B,H)6.*F.*L.*((B.*H.^2).^-1)-50, ...
@(B,H)4.*F.*L.^3.*((E.*B.*H.^3).^-1)-12.7, ...
}
cP = 1×3 cell array
{@(B,H)H.*(B.^-1)-6} {@(B,H)6.*F.*L.*((B.*H.^2).^-1)-50} {@(B,H)4.*F.*L.^3.*((E.*B.*H.^3).^-1)-12.7}
figure
fimplicit(cP,interval);
Since it is undocumented, I don't which MATLAB versions support this, so you may have to use each one separately:
figure
for ii = 1:numel(cP)
fimplicit(cP{ii},interval);
hold on
end
  2 Kommentare
Michael Haag
Michael Haag am 20 Sep. 2023
Bearbeitet: Michael Haag am 20 Sep. 2023
@Voss: Perfect thank you, this helps!
Interesting that fimplicit accepts a cell array of function handles.
Voss
Voss am 20 Sep. 2023
Bearbeitet: Voss am 20 Sep. 2023
You're welcome!
Yeah, I was surprised to discover (accidentally, while writing my answer) that the cell array of function handles works. The documentation lists only a function handle as the supported class for the first input to fimplicit (no mention of cell arrays):

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by