GNUPlot combining loops and column scaling - loops

I have a dataset with multiple columns of data, which I plot using a loop
plot for [i=2:19] 'myfile.txt' using 1:i
I would like to scale my data by dividing by 1024. Outside of a loop I can do this with:
plot 'myfile.txt' using 1:($2/1024)
I would like to combine these two, but the following does not work:
plot for [i=2:19] 'myfile.txt' using 1:($i/1024)
I imagine it is to do with the order that the substitutions are happening in.
Can any one show me an elegant solution here?
Many thanks

You can use column(i) instead of $i:
plot for [i=2:19] 'myfile.txt' using 1:(column(i)/1024.)
should work.

Related

why implementing in matlab planar array formula went wrong

I have tried to implement the formula shown below in matlab to create the plot shown below.
But when I implemented the formula using the code below I get a totally different plot as shown below.
Where did I go wrong?
[theta,phi] = meshgrid(-pi:0.2:0.5*pi,-pi:0.2:pi);
f=10;
lambda=300/f;
k=(2*pi)/lambda;
N=10;
M=10;
dx=0.5*lambda;
dy=0.5*lambda;
ksi_x=k*dx.*sin(theta).*cos(phi);
ksi_y=k*dy.*sin(theta).*sin(phi);
AF=((1/M)*((sin(0.5*M*ksi_x))./(sin(0.5*ksi_x)))).*((1/N)*((sin(0.5*N*ksi_y))./(sin(0.5*ksi_y))));
surf(phi,theta,AF)
colorbar
The plots you provided are not based on (Θ, φ), they're of Ψ_x and Ψ_y.
Just replace surf(phi,theta,AF) with surf(ksi_y, ksi_x, AF) and you'll have it.

How can I store images in an array in octave?

I have an read image got with the imread function.
Now, I need to create a random number of images with noise, appling the noise function.
The main problem is: The amount of images will be random. so I tried to create a cell array and store the images in each position (array(1)=img1, array(2)=img2, and so on). But using it, the array(1) and so on doesn't let me work with my image.
So how can I really put all of them in a array and use them normaly?
Tank you!
MATLAB and Octave have pretty much the same language.
Please try the following:
for i=1:length(images)
array_of_images{i}=images(i);
end
I think it should work something similar or exactly this

Repairing pixelated image using matlab Help needed

http://i.imgur.com/j7hStIG.png
Hi I need help repairing this image using for loops. I know I have to identify the bad pixels first and fill them in. thanks. PS I am very new to matlab
clear
clc
format compact
filenameIN = uigetfile('.bmp','Picture');
noisyRGBarray = imread(filenameIN);
figure(1)
imshow(noisyRGBarray)
y = noisyRGBarray;
[m,n]=size(y)
clean=[];
for i=2:m-1
for j=2:n-1
if y(i,j)% clean add new
clean = [ clean, y(i,j) ]
end
end
end
Im pretty sure the for statemetn is wrong and I do not know wat to do from here. I need help writing the for loop to go through the image matrix to identify the black and white pixels.
Try running a median filter on your image. See here for an example.
If you must use a for loop for learning reasons, please explain what you consider to be a "bad pixel" (black? different from neighbors in some way?), attempt to identify such a pixel based on the criteria you settle on, and adjust the value of that pixel.
In general, you should not adopt the approach of starting with an empty array and growing it one pixel at a time. Rather, create the output image as a copy of the input (clean=noisyRGBarray;) or initialize with zeros (clean=zeros(size(noisyRGBarray))), and modify the bad pixels (clean(i,j,:)=...);

How to create multiple vertical lines jfreechart

I want to create verical lines , the thing is , for example i have a space between x=0 and x=20 , and i have a jtextfield where the user can digit a number , and that number will create the same number of vertical lines in that space of x=0 and x=20. i'm using xyplot , and the problem is , if i use the same series to add the points i will get a zigzag line , for exemple if i do:
series.add(0,-2)
series.add(0,2)
series.add(4,-2)
series.add(4,2)
So for differents coordenate xx i have to have a different seried . But if i do a different series i have to do a diferente dataset too, because when i try to add different series to the same dataset i get a error. i thought about using a for loop to create differents dataset and differents series , but i have no ideia how can i do that . i could use the grid line to do this , but i only want to see the lines between x=0 and x=20 , and i don't know if i can do that with the grid line , and i don't know how to change the space between grid lines .
So maybe you can tell me so ideias about this , and if you could guide me , that would be great.
There is a facility in JFreeChart to add "markers" to a plot to mark particular values along an axis. The markers are typically drawn as lines across the plot, perpendicular to the x-axis (domain markers) or the y-axis (range markers). In your case, it sounds like you want to add a fixed number of domain markers to the plot, so you should call the addDomainMarker() method on the plot.

drawing graphs in ubuntu

I have a C code that collects data and places them in a 2-D array. I would like to plot this data on an x-y graph (mathematics) automatically i.e. pass the data as parameters in a command line and get a graph
Are there any suggestions for how to do so?
gnuplot is a good one to look at assume you mean x-y charts, if you want actual graphs then look at dot
gnuplot will do what you need. If you want to process the data before, you might want to try octave, which aims to be a matlab equivalen (still uses gnuplot as a frontend for graphing).
If you want even more control, you could write a script in python and use matplotlib.

Resources