I think this is a simple question, but I could not find an answer by googling.
Let's say that I have a code like this:
y1=1:0.01:2;
This creates 1x101 long cell, with numbers 1, 1.01, 1.02, 1.03, 1.04, etc. Now I want to have an array of numbers which goes like 1, 1+0.01i, 1+0.02i, 1+0.03i, 1+0.04i, 1+0.05i, 1+0.06i, 1+0.07i, 1+0.08i, etc. I thought that the code 1:0.01i:2;
will give the answer, but I am getting a warning
Warning: Colon operands must be real scalars.
How to get around this?
Thanks in advance
As the warning message is trying to tell you, the :
is meant to be used in only one dimension. It cannot keep the real part constant and only increase the imaginary part. Instead, do this:
y=0:.01:1;
z=1+i*y
and z
will contain the values you want. Here is the relevant docs .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.