How can i simulate this equation on Matlab m.file?

Risposte (1)

It is not clear what your desired outcome is.
[Pt{1:4}] = ndgrid([-1.113+20.691i,-1.113-20.691i],[-2.156+12.654i,-2.156-12.654i],[-0.901+1.893i,-0.901-1.893i],[-0.0062+0.0531i,-0.0062-0.0531i]);
P = [Pt{1}(:),Pt{2}(:),Pt{3}(:),Pt{4}(:)];
The above would leave P as a matrix in which each row expressed one of the possibilities.

5 Commenti

I tried it with matlab , it didn't give any result
The above would create a variable named P. You can display the variable, such as by
disp(P)
I wrote it like this:
[Pt{1:4}] = ndgrid([-1.113+20.691i,-1.113-20.691i],[-2.156+12.654i,-2.156-12.654i],[-0.901+1.893i,-0.901-1.893i],[-0.0062+0.0531i,-0.0062-0.0531i]);
P = [Pt{1}(:),Pt{2}(:),Pt{3}(:),Pt{4}(:)];
disp(P)
and this is the result
-1.1130 +20.6910i -2.1560 +12.6540i -0.9010 + 1.8930i -0.0062 + 0.0531i
-1.1130 -20.6910i -2.1560 +12.6540i -0.9010 + 1.8930i -0.0062 + 0.0531i
-1.1130 +20.6910i -2.1560 -12.6540i -0.9010 + 1.8930i -0.0062 + 0.0531i
-1.1130 -20.6910i -2.1560 -12.6540i -0.9010 + 1.8930i -0.0062 + 0.0531i
-1.1130 +20.6910i -2.1560 +12.6540i -0.9010 - 1.8930i -0.0062 + 0.0531i
-1.1130 -20.6910i -2.1560 +12.6540i -0.9010 - 1.8930i -0.0062 + 0.0531i
-1.1130 +20.6910i -2.1560 -12.6540i -0.9010 - 1.8930i -0.0062 + 0.0531i
-1.1130 -20.6910i -2.1560 -12.6540i -0.9010 - 1.8930i -0.0062 + 0.0531i
-1.1130 +20.6910i -2.1560 +12.6540i -0.9010 + 1.8930i -0.0062 - 0.0531i
-1.1130 -20.6910i -2.1560 +12.6540i -0.9010 + 1.8930i -0.0062 - 0.0531i
-1.1130 +20.6910i -2.1560 -12.6540i -0.9010 + 1.8930i -0.0062 - 0.0531i
-1.1130 -20.6910i -2.1560 -12.6540i -0.9010 + 1.8930i -0.0062 - 0.0531i
-1.1130 +20.6910i -2.1560 +12.6540i -0.9010 - 1.8930i -0.0062 - 0.0531i
-1.1130 -20.6910i -2.1560 +12.6540i -0.9010 - 1.8930i -0.0062 - 0.0531i
-1.1130 +20.6910i -2.1560 -12.6540i -0.9010 - 1.8930i -0.0062 - 0.0531i
-1.1130 -20.6910i -2.1560 -12.6540i -0.9010 - 1.8930i -0.0062 - 0.0531i
Yes, that looks correct as far as it goes.
As I indicated above "It is not clear what your desired outcome is.".
You will not be able to get a formula that uses the ± character.
You can create a character string,
'-1.113±20.691i, -2.156±12.654i, -0.901±1.893i, -0.0062±0.0531i'
It happens that the ± character is position 177, which should be preserved even if you are not using UTF-8 encoded .m files.
If you want to display in a graph then, for example,
x = 0.1; y = 0.1;
text(x, y, '$-1.113{\pm}20.691\mathrm{i}, -2.156{\pm}12.65\mathrm{i}, -0.901{\pm}1.893\mathrm{i}, -0.0062{\pm}0.0531\mathrm{i}$', 'interpreter', 'latex')
Note: in the case of displaying like this, your particular field of mathematics or physics might prefer to use a different representation of the imaginary unit. The ISO standards say that invariant constants should be set as upright roman characters, but there are other fields of mathematics and physics that prefer italic for the imaginary unit, or prefer j for the imaginary unit. With italic, you have to be careful about the potential for conflicts with using i as a subscript.

Questa domanda è chiusa.

Richiesto:

il 27 Lug 2018

Chiuso:

il 20 Ago 2021

Community Treasure Hunt

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

Start Hunting!

Translated by