plot a complex data

2 次查看(过去 30 天)
John
John 2015-1-9
I have been trying to plot a data of magnetic fields obtained from a commercial software. So, far my code is:
[dataBx, dataBy, dataBz]= ReadData(infoFile, gemFile, dataFileBxr, dataFileBxi, dataFileByr, dataFileByi,dataFileBzr, dataFileBzi);
x = (dataBx);
y = (dataBy);
z = (dataBz);
img = (((imag(x) - ((1i)).*(imag(y))/2)));
clims = [min(min(img)) max(max(img))*1E-1];
subplot(2,1,1);
hold all
plot (img)
colormap jet;
subplot(2,1,2);
h_img = imagesc(rms(img));
axis square;
colormap jet;
dataBx, dataBy and dataBz consists of complex numbers which I read in first two line. Then, I stored it in x, y and z respectively. Then, I used the formula: (img=(B1x-B1y)/2). So, here in this code, I represented B1x as x and B1y as y.
Then, I tried to plot it and get the value of magnetic field in colormap values as I obtained from a commercial software. But, I am not able to get that value. I don't know what is wrong here. Can anyone suggest me something? I have tried a lot of things but I am not able to work it out.
May be the formula of clims is wrong.
  2 个评论
John
John 2015-1-9
I think I found the problem but I dont know how to solve it. In the workflow window. It shows that the size of h_img is 1x362 while the size of dataBx, dataBy and dataBz is 313x362. So, I think this value is responsible for the wrong image. Does anybody know which portion affects the size of img and how to optimize it?
Thank you for reading.
John
John 2015-1-9
编辑:John 2015-1-9
This is not the problem. I optimized the code. and found somewhat better result. How can I make this image smooth in the middle. It shows some lines in the below image. If it could be made smoother, it could be more meaningful.

请先登录,再进行评论。

采纳的回答

David Young
David Young 2015-1-9
The call to plot
plot (img)
looks wrong, because img is 2-D. I would expect you to be using image(), imagesc() or imshow() to inspect the array at this point.
The call to imagesc
h_img = imagesc(rms(img));
looks wrong because rms(img) is 1-D. I would expect you to be using plot() at this point, assuming that you do want to see the rms of each column of img (which is what rms() computes).
  2 个评论
John
John 2015-1-9
编辑:John 2015-1-9
Thank you for your answer Mr. David Young. I optimized the code and till now I got the image as shown in the above comment. Can you help in optimizing more of this image so that it looks more smoother. I have attached the optimized code with that comment too.
Regards, John.
David Young
David Young 2015-1-10
If the issue is image smoothing, you can smooth an image by convolution with a Gaussian. If you search answers, you'll find some suggestions about how to do this.
If that doesn't help, I think different issues are coming up now, and the best way forward would be for you accept my answer (if you feel it was useful) and to start a new question about the smoothing issue, with your current code.
(By the way, "optimized" does not normally mean "debugged". It means adjusted to minimise some measure of the use of resources.)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Blue 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by