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.
Related
so I have a formula inside an array that looks like this
={CRYPTOFINANCE("kraken:"&ARL8&"/USD", "price_history", "10d")}
I want to auto fill the array with the same function but with the 'ARL8' reference in an ascending order, just like auto filling cells, but keep it all in one cell it should look like this...
={CRYPTOFINANCE("kraken:"&ARL8&"/USD", "price_history", "10d") ; CRYPTOFINANCE("kraken:"&ARL9&"/USD", "price_history", "10d") ; CRYPTOFINANCE("kraken:"&ARL10&"/USD", "price_history", "10d")} ,SUBSTITUTE(TRANSPOSE(SPLIT(REPT(12,1050),2)),1,"MISTAKE")) etc.
the thing is that I have about 1000 values from ARL8 reference to ARL1008 reference so it will take really long for me to write it all manually, so is there a way I can keep the rest of the function but have the ARL cell reference dynamically written while being able to specify the length of the array?
It's something I am struggling for a while now and still couldn't find a way so I really appreciate if you could explain the solution as well, and if there is more info I can give let me know, and thanks.
I tried a few things but they gave me different errors I didn't know how to solve and others just didn't work, I will just put it in case it helps
=ARRAYFORMULA(CRYPTOFINANCE("kraken:"&ARL8:ARL1008&"/USD", "price_history", "10d"))
the error it gave me is - "error Attribute price_history isn't supported in batch formulas"
try:
=BYROW(ARL8:ARL20, LAMBDA(x, CRYPTOFINANCE("kraken:"&x&"/USD", "price_history", "10d"))
update
you can generate a formula with a formula like:
={""; INDEX("=ARRAYFORMULA({SPLIT(""Exchange,Base,Quote,Time,Open,High,Low,Close,Quote Volume,Base Volume"", "","")"&
QUERY(";QUERY(TO_TEXT(CRYPTOFINANCE(""kraken:""&"&C2&
SEQUENCE(C3, 1, C4)&"&""/USD"",""price_history"",""10d"")), ""offset 1"", )",,9^9)&"})")}
demo sheet
im new to programming and im working with a MRI dataset (.nii) in PyVista
Im trying read the Nifti File and extract an array so i can compare two MRIs based on the differences in the array and visualise it with PyVista.
PyVista is mostly based on the VTK library so maybe there is a function in VTK but im a bit helpless looking through the Docs.
I found a solution in nibabel to access an array:
img = nib.load(example_filename)
a = np.array(img.dataobj)
But with that i still can't access the PyVista Array to highlight the differences.
Thank you for your help in advance!
We need to perform two distinct operations:
retrieving the intensity values from your NIfTI dataset using, for instance, nibabel
plotting the 3D numpy array using, for instance, PyVista. Take a look at the PyVista documentation here and here for further details. You will have to add origin, spacing, etc. but for the sake of simplicity I am going to omit them.
Here is the code:
import nibabel as nb
example = nb.load("/nifti/path/example.nii.gz")
intensities = example.get_fdata()
grid = pv.UniformGrid()
grid.dimensions = np.array(values.shape) + 1
grid.cell_data["intensities"] = intensities.flatten(order="F")
grid.plot(volume=True, cmap="bone")
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.
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:).
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