Blank Plot showing when plotting a function - wolfram-language

When I input the function (A1[.2])Exp(t*plus[.2])+(A2[.2])Exp(t*minus[.2]), where A1[x], plus[x], A2[x], and minus[x] are predefined functions, I get an output of a plot with no function on it.
(Ideally, I'd be able to generalize this function so that the .2 could be replaced with a variable that has a slider and would update live on a graph, so any assistance with that would be great too)
I'm pretty new to Wolfram (picked it up today) so I'm not too sure what syntax errors there could be, but I assume it's an issue with syntax, since that's always the issue in similar problems on here.
In the code below, I do get the correct answers for A1[.2],A2[.2],plus[.2], and minus[.2], and when I actually plug these numbers in and input it in Wolfram Alpha, it comes out with the exact graph I'm looking for. However, on here, no dice.
Here is the code that I have:
{gr,kk,ma,po,ve} = {10,5,1,1,-1}
det[x_] := ((x*gr)^2-(4*kk/ma))^.5
plus[x_] := (-x*gr+det[x])/2
minus[x_] := (-x*gr-det[x])/2
xv = {{po},{ve}}
A1[b_] := Inverse[{{1,1},{plus[b],minus[b]}}][[1]].xv
A2[b_] := Inverse[{{1,1},{plus[b],minus[b]}}][[2]].xv
Plot[(A1[.2])Exp(t*plus[.2])+(A2[.2])Exp(t*minus[.2]),{t,0,5}]
The graph should look like a sine function that gets smaller and smaller in magnitude as t increases, but there is a plot shown and no function shown in the plot. This is what it should look like:

Related

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:).

Strange behavior with Matlab array

I am having some trouble manually creating a histogram of intensity values from a grayscale image. Below is the code that I am using the create the bins for the plot that I want to create. The code works fine for every bin except for the last two. For some reason if the intensity is 254 or 255 it puts both values into the 254 bin and no values are accumulated in the 255 bin.
bins= zeros(1,256);
[x,y]=size(grayImg);
for i = 1:x
for j = 1:y
current = grayImg(i,j);
bins(current+1) = bins(current+1) + 1;
end
end
plot(bins);
I do not understand why this behavior is happening. I have printed out the count of 254 intensities and 255 intensities and they are both correct. However, when using the above code to accumulate the intensity values it does not work correctly.
Edit: Added the image I am using, the incorrect graph(the one I get with above code), and the correct one
A. The first problem with your code is the initial definition of bins. It seems that you come from C or somthing like that, but the definition should be- bins=zeros(1,256);
B. The second point is that you don't need the nested loop, you have a matlab function especially for that:
bins=hist(grayImg(:),1:256); % now, you don't need the pre-definition for 'bins'.
plot(bins);
C. Try to use functions like bar or imhist or hist(grayImg(:)), it may save you all this, and give a nice plot.

Find the inverse of a sequence in integers in Mathematica

Let k[i] is a strictly increasing data and
A=Table[k[i],{i,1,30}];
B=List[k[1],k[3],k[4],k[7],k[10],k[12],k[17],k[18],k[19],k[23],k[26]];
Now I would like to get what is the index for B[n], for example B[4]=A[7], and my question is to get 7. I tried InverseFunction,
InverseFunction[A][B[4]]
but it does not work. A similar question arise when I define A and B by the following sets
A=List[k[1],k[2],k[3],k[4],k[5],k[6],k[7],k[8],k[9],k[10],k[11],k[12],k[13],k[14],k[15]];
B=List[k[1],k[3],k[4],k[7],k[10],k[12],k[14]];
If the problem is in the method of representing data by the function List, please let me know a better way.

How to center a map on something other than the prime meridian in d3.js?

This is a similar question to this one (which was answered for ggplot2), this one (which was answered for R) and is a follow up question to this one (which is still looking for an answer).
How could I use this recent Constrained Zoom plot by Mike Bostock (http://bl.ocks.org/mbostock/4987520) but have the starting position with the pacific in the center rather than Africa?
Like this...
Obviously just adjusting the .translate([0, 0]) values in the code moves the map, but there is no 'wrapping' that would allow the map to be presented as above.
I am convinced that there must be a simple way to accomplish this, as it seems like a fundamental capability, I just can't see or find a solution.
OK, The answers was pretty obvious in the end and many thanks to the guys at Hashbang whose post set me on the right path.
The problem I was having was assuming that I needed to use the .translate() function to shift the map to the correct location, when in fact the .translate() function just moves the points on the returned map. So in other words it literally translates what you have to another location (duh!).
What I should have done is use the .rotate function to rotate the map about its longitude by using the function like so;
var projection = d3.geo.mercator()
.translate([0, 0])
.scale(width)
.rotate([-180,0]);
This simply wraps the map around and gives full control as desired.
A fully functioning example is here.

Is there a C lib to find peaks in noisy data equivalent to findPeaks.m

i have a noisy set of data and want to find the peaks in it. There is a matlab function for this exact task which includes smoothing of the data. I is called findpeaks.m
Now as im working in C i would either would have to code this by myself or use some functions which im not aware of. I hope you can tell me if they exist and where i can find them, as this is a very common problem.
To be clear what im searching of: a function to first smooth my data and then calculate the peaks, both preferably with some parameters for smoothing method, peak width etc.
Thanks!

Resources