LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calculations in 2D array

Solved!
Go to solution

@RavensFan wrote:

How do you evaluate (inputfile >> E1 >> C1) and

outputfile << E2 << " "<< C2 << endl;

 

My understanding is that >> and << mean right and left shifts.  But that doesn't make sense in the context those operators were used in the program.


std::ostream overloads these operators for file I/O. It's basically move it into the file or out of the file.

The "outputfile << E2 << " " << C2 << endl;" gives something like a string constructed by appending all the elements (effectively from right to left).

 

Technically they produce a stringstream and take a stringstream as arguments, so it's something like outfile << (E2 << ( " " << ( C2 << std::endl; ) ) ); where each bracket pair produces a valid input to the next leftmost element. See http://www.cplusplus.com/reference/ostream/ostream/operator%3C%3C/ if you care to read more. Or just use LabVIEW and happily forget about it all 🙂


GCentral
Message 11 of 18
(1,340 Views)

Here's my "best effort" attempt at your code.

But I don't get exactly the same values as yours for the first case, and not at all for the most recent input/output pair.

 

The 11 spaces is a little problematic reading the file - it seems a bit arbitrary (although of course it can be handled, it's a little strange).

Is it some sort of tab -> space issue with some editor?

 

Edit: looking at your recently uploaded .C file I think probably I'll get the same results as you for the first page if I change the "B" value - in your original code you gave 1.0006, but in your .c file you have 1.00027. I'm guessing that might be enough (at least in the first case).


GCentral
0 Kudos
Message 12 of 18
(1,339 Views)

Yes, looks mostly like some kind of resampling assuming a slight nonlinearity in the x-scale.

 

Even if I assume linear scales and double the Y, I get pretty close. (maybe within noise!?)

 

So all you probably need to add are a few nonlinear tweaks based on your values.

 

 

altenbach_0-1585238079843.png

 

Message 13 of 18
(1,334 Views)

@cbutcher wrote:


....... Or just use LabVIEW and happily forget about it all 🙂

I like that answer.

 

That << usage in this case seems like some arcane syntax where there is are much more commonly used methods to get the same end result.

0 Kudos
Message 14 of 18
(1,309 Views)

Actually, there is no constant algorithm for this calculation.

What I want to do is make a re-binning process for the energy axes (column 1), to compress it from around 1 keV interval to be 2 keV or more interval. the goal of this process is to increase the results statics because the measurement time is too short and with the current conditions the noise of the spectrum will be so high. 

this is my idea and I already use it before in my work.

but I get the general ideas from the attached paper. you will find it clear on page 2. 

for your information, I modified this idea to be the code that I shared with you.

 

about the distances between the column, it is not so important. I can control it easy or change it to "," or deny interval. or we can change the input file to be .xls file in 2 columns.

0 Kudos
Message 15 of 18
(1,289 Views)

your current LabVIEW version is later than mien, can you please share it again with me! .. i am used LabVIEW 2018

0 Kudos
Message 16 of 18
(1,287 Views)
Solution
Accepted by topic author Khallod

Here's mine as LabVIEW 2018.

altenbach's appears to have been saved back to 2015, so you should have no problem with that if you want to use/test it.


GCentral
0 Kudos
Message 17 of 18
(1,277 Views)

It is a very smart idea, I will modify it to match the expected results. 

really great effort 😊

 

0 Kudos
Message 18 of 18
(1,273 Views)