How can I visualize the 3D results from Femlab in Octave / Gnuplot? - matrix

I have some data from model in Femlab. Because I would like to work on the results more, I would like to use Octave / Gnuplot as well to visualize the computed data. I have exported the data from Femlab into a txt file in form "x y z value" (4 columns). Everything unsorted - than can I do. But how to get this into gnuplot? I can choose one of the variables to fix it(let's be it x) and plot the rest y,z and value by splot. But, I have thousand and thousand of numbers and this is not possible, than Femlab doesn't keep the variables fixed (so you sort it along x and find out that there are no two x values the same).
I know about Femlab / Matlab interface, but unfortunately I havent Matlab.
Thank you in advance!

Have you tried scilab? It is a matlab clone like octave and seems to support some FEM stuff: http://wiki.scilab.org/Finite%20Elements%20in%20Scilab.
See also http://www.utc.fr/lrm/giens05/CDROM/CDROM/lo01.pdf a paper where they interface Scilab and OpenFEM.

Related

How to plot or show multiple images in a row using julia?

I'm new to Julia and I used MNIST handwritten digit train data to get multiple images in matrix with size 28 x 28. Let's assume I store them in array img[i] with length n(n is dynamic). I want to show Images in one window such that every image has its own specific label under it.
I tried to search and read documents, currently I use hcat(images_window, img[i]) for all images and plot(images_window) and annotate some text label for each image in specific coordinates. This way is not a good practice and n is not configurable either.
I expect Julia have something like dynamic layout for its plots and I can show Image in each subplot and show them in a window with something like this:
plt = plot()
for (i, subplot) in enumerate(plot)
plot!(plt, subplot, layout(i))
end
display(plt)
You didn't mention which plotting library you are using but from the basic syntax I'm vaguely guessing that you might be asking bout Plots.jl.
In Plots, plotting multiple subplots on one figure in principle works like this:
using Plots
p1 = plot(rand(5))
p2 = plot(rand(5))
plot(p1, p2)
i.e., you call plot with multiple arguments which themselves are plots. You can then additionally specify a layout kwarg, which in its simplest form takes a tuple of (nrows, ncols) and places the subplots in a grid with the specified number of rows and columns.
As an example, here's three plots next to each other:
plot(plot.([rand(5) for _ ∈ 1:3])..., layout = (1, 3))

Gnuplot : plot data from file using expressions fails

I am plotting some data (https://jpst.it/23X01) with gnuplot and I am having a weird problem when combining "using" with an expression on the columns.
The basic command
gnuplot> plot "test.dat" u 1:4 w l
works just fine and displays the following graph
complete curve with gnuplot
But if I use an expression instead
gnuplot> plot "test.dat" u 1:($4) w l
, some data is discarded.
curve with missing points
The discarded points seem to coincide with low y-values. The problem was observed with both v4.6 patchlevel 6 and v5.0 patchlevel 5.
Am I getting something wrong ? I have used this functionality of gnuplot several times in the past but never had this problem before. Thanks in advance.
I thought of deleting my question as I found my problem and it is silly, but since others might make the same mistake, I am leaving it for now.
My datafile was not formatted correctly and some columns were "jammed" together (I am amazed gnuplot managed to plot it with the first command). For example:
1415.8510073.5710065.88 61.32 61.58
instead of
1415.85 10073.57 10065.88 61.32 61.58
After I separated the columns correctly, everything went back in order.

MATLAB -Exponential (exp2) curve fitting function not giving the same output as the plot graph when using the fit values in the original equation

my brain is pickled with this one. Below are the two graphs I have plotted with exp2 function. The points do not match the curve, and this is ultimately changing my entire answer, as it is giving the wrong values out, and I cannot understand why?
enter image description here
enter image description here
Here is the code I am using, both graphs plot a concentration against time, but yet give different results:
CH4_fit = fit(Res_time, CH4_exp, 'exp2'); CH4_coeff =
coeffvalues(CH4_fit);
%Co-efficient values for exponential fitting CH4_pred
=(CH4_coeff(1)*exp(CH4_coeff(2)*Res_time)) + ...
(CH4_coeff(3)*exp(CH4_coeff(4)*Res_time)); plot(Res_time,CH4_exp, Res_time, CH4_pred);
Can I just added that the exact same data was run on different computers, and it gave the same equation co-efficients exactly (to 4.dp) and the same times, but yet still outputs different concentrations on my version? I have the R2018b, and I have just used default settings (don't know how to change anything, so I definitely haven't).

Feature Scaling, how to standardize

Well I've an image and a vector, the vector consists 3 datas, positonX, positionY and Intensity(0-255).
How do I standardize this, should standardization be done for each pixel or for an entire column, Also once standardized, for example I take the mean of 5 pixels, how do I get the original values(destandardize) back?
Can you please elaborate what are you trying to achieve and platform you are using in case you are using R you can try a package called imager. ..let me know if it helps

"Submatrix incorrectly defined" when trying to decrease color depth of greyscale images

I'm trying to make Scilab receive a certain JPEG image then transform it into a matrix of values between 0 and 255 (normal 8bit depth image) and then rearrange those values into smaller depths. The proposal is to make all the options from 1bit to 7bits which translates into 2, 4, 8, 16, 32, 64 and 128 different levels of color for them respectively.
We're doing it with greyscale images to make things simpler, since we can simply get any of the 3 channels and work with it as a matrix of rows and columns. I know there are many better ways of doing this, but I need to do it using Scilab since it's for a image processing course at University (signals and linear systems subject from Electrical Engineering to be exact).
What I could come up with, and it worked fine for the test-matrices that I tried, is this:
function y=bits(x,p)
[rows, columns]=size(x);
y=zeros(rows,columns);
aux=round(linspace(0,255,2^p)); //define which values the output can have
for i=1:rows //varies rows
for j=1:columns //varies columns
[aux2,minpos]=min(abs(aux-x(i,j)));//calculates the closest value between the input and the possible output values
y(i,j)=aux(minpos); //get the calculated closest value and puts it at the output
end
end
endfunction
What I can't understand is why it works fine for any hand-made matrix but when I try to send it something bigger (I mean, which more rows and columns) it gives the "Submatrix incorrectly defined." error at line 8 which is the " y(i,j)=aux(minpos);" line.
Edit: Just to add, I'm importing the image using "imread", which is a function of SIVP.
Any help is appreciated, thanks in advance =)
I could fix it with the following at the beginning of the function:
x=x(:,:,1);
x=double(x);
=).

Resources