How to get interpolated value for 1D array in LabVIEW? - arrays

I have two 1D arrays that gives an array of points on the XY plane. What I am trying to achieve is to find that steps interpolation for which values is exactly 0.5. I've tried to solve it using Interpolate 1D array and Threshold 1D array but no success. The first only returns values information for which steps == 0.5 and the latter is not doing anything apparently, returning 0 always.
I've attached the front panel and block diagram to the post. On the front panel I indicated which information I need.
Could you please help me figure out what I am doing wrong here? Because I'm quite stuck with this. Thank you in advance.

Kudos for solving it yourself, but a vi post of the solution would be appreciated for further reference by other people. Here is a solution that uses the 1D interpolation from the mathematics section. One VI, only downside is that you need to convert you interpolation value to an array and the answer back.

I managed to solve it. Threshold 1D array vi cannot deal with arrays that contain decreasing values... a rather frustrating error, as I need to transform the array so that the characteristics become increasing to obtain the interpolated value.
From the documentation:
Note Use this function only with arrays sorted in non-descending
order.

Related

Using N-D interpolation with a generic rank?

I'm looking for an elegant way of useing ndgrid and interpn in a more "general" way - basically for any given size of input and not treat each rank in a separate case.
Given an N-D source data with matching N-D mesh given in a cell-array of 1D vectors for each coordinate Mesh={[x1]; [x2]; ...; [xn]} and the query/output coordinates given in the same way (QueryMesh), how do I generate the ndgrid matrices and use them in the interpn without setting a case for each dimension?
Also, if there is a better way the define the mesh - I am more than willing to change.
Here's a pretty obvious, conceptual (and NOT WORKING) schematic of what I want to get, if it wasn't clear
Mesh={linspace(0,1,10); linspace(0,4,20); ... linsapce(0,10,15)};
QueryMesh={linspace(0,1,20); linspace(0,4,40); ... linsapce(0,10,30)};
Data=... (whatever)
NewData=InterpolateGeneric(Mesh,QueryMesh,Data);
function NewData=InterpolateGeneric(Mesh,QueryMesh,Data)
InGrid=ndgrid(Mesh{:});
OutGrid=ndgrid(QueryMesh{:});
NewData=interpn(InGrid{:},Data,OutGrid{:},'linear',0.0)
end
I think what you are looking for is how to get multiple outputs from this line:
OutGrid = ndgrid(QueryMesh{:});
Since ndgrid produces as many output arrays as input arrays it receives, you can create an empty cell array in this way:
OutGrid = cell(size(QueryMesh));
Next, prove each of the elements of OutGrid as an output argument:
[OutGrid{:}] = ndgrid(QueryMesh{:});

ARKit: Reproducing the Project Point function

I'm attempting to reproduce the ARCamera's project point function, but for some reason the values are not matching up properly. I am taking the ARCamera's projection matrix and view matrix and applying basic CG perspective transform math, (PV) * p, but the NDC values do not match the pixel values given from the ARCamera's project point function. Any ideas? Am I forgetting something?
Some more detail:
Basically, I'm trying to take an ARFrame a the click of a button, and then trying to replicate the functionality of https://developer.apple.com/documentation/arkit/arcamera/2923538-projectpoint. I'm attempting to do this with https://developer.apple.com/documentation/arkit/arcamera/2887458-projectionmatrix and https://developer.apple.com/documentation/arkit/arcamera/2921672-viewmatrix, making sure all of the inputs match for both parts. CG size is used to transform the coordinates from NDC space to image space.
EDIT: Solution found, check comments below.
The problem turned out to be projection_matrix sometimes does not correctly find the device orientation. The correct approach is to use projectionMatrix(for:viewportSize:zNear:zFar:).

How to comunicate between two array lists

I want to compare two array lists, when i press list1 items, open list2 items in new activity.please help me. i have write below code but not working. please solve my problem.I want to compare two array lists, when i press list1 items, open list2 items in new activity.please help me. i have write below code but not working. please solve my problem.
//My String-array
<string-array name="Alphabets1">
<item>A</item>
<item>B</item>
<item>C</item>
<item>D</item>
<item>E</item>
<item>G</item>
<item>H</item>
<item>I</item>
<item>J</item>
</string-array>
<string-array name="Lyrics1">
<item>Aakaashamandunna </item>
<item>Bangaram Adagaledu</item>
<item>Cheyi Pattuko</item>
<item>Devara Nee Devenalu</item>
<item>Ella velalandu kastha</item>
<item>Gaganamu Cheelchukoni</item>
<item>Hallelujah Hallelujah</item>
<item>Ide Naa Korika</item>
<item>Janminchenu Oka Thaara</item>
</string-array>
<!-- begin snippet: js hide: false -->
You actually have a few problems to solve here. One of them is the difference between ArrayLists and arrays - I'm pretty sure you mean arrays here, since ArrayLists only hold objects, and there wouldn't be much point in forcing autoboxing and unboxing for a slower-access collection. But maybe you mean ArrayLists because you want the built-in expandability, I don't know. Something for you to determine.
I'd start with one of the sub-problems: combining two arrays or arraylists, preferring non-zero values. You'll do about the same thing with different syntax in each case.
Write a method int[] combine(int[] firstArray, int[] secondArray) to walk two arrays simultaneously and combine the values you find. You'll have to figure out what the correct behavior is when you have two non-zero values. (or are you simply summing the arrays? that'd be pretty easy)

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

MATLAB C matrix interface: does mxDestroyArray recursively destroy elements of cells and structs?

The question is in the title: does mxDestroyArray() recursively destroy elements of cells and structs? Is is about MATLAB's C matrix library interface.
To explain in more detail through a concrete example, suppose that I create a 1 by 1 cell using mxCreateCellArray(), then create a numeric matrix using mxCreateNumericArray() and set it as the only element of the cell. Now will calling mxDestroyArray() on the cell destroy the numeric array as well, in one go? Or do I need to call it separately for the numerical array, then the cell? I am hoping for the latter, as this is more reasonable for complex manipulations.
The documentation is ambiguous on this point. Also, it's not easy to devise a test that would give a definitive answer to this.
According to the reply I got on MATLAB answers, mxDestroyArray() does free elements of cells and structs recursively. Please see that answer for an example program that confirms this.

Resources