Trying to populate an array from a text file - arrays

I'm using xcode, swift 5.0.
I have a multidimensional array for a tableViewController to give a list with different sections.
I would like for the array to be taken from a text file which is stored remotely (so that the array contents can be updated without an app update).
Any advice on how to code for this?

Related

How do I replace an array element in LabView? (2d array of pictures)

so I have a final project for a class where I need to make a video game in LabView. The issue I'm having at the moment is that I can't figure out the 'right' way to put 'yourShip.png' into the 2d array of 2d pictures at [0,0]. Every tutorial I can find basically has exactly what I have down below in the screenshot, and it makes sense to me. However, running the program quickly shows that it does nothing.
To describe the code, I have a path constant that leads to the picture, which feeds to a draw flattened pixelmap function. Up to this point I know the code works, since creating a test indicator reveals as such. However, next I try to use the replace array subset function to replace the (default blank) 2d picture at [0,0] with yourShip.png. 'screen' is a 5x5 2d array of 2d pictures. The local variable of the same name being outputted to is indeed the very same array.
My main guess with why my code doesn't work is because of the way I'm taking screen as the input variable and then outputting to it via a local variable. However, if this is wrong, I'm confused with how I should do it. All I want to do is 'spawn' the image at the correct index.
The replace array subset works quite literally, i.e. it can only replace existing elements.
If there is no element at the specified index because the array is smaller, the function will do just nothing.
I guess your array is empty, so, initialize your screen array first to a size of at least 1x1.

Displaying array with xCode Cocoa App

Hi,
I m new in xcode programming, I would like to simply display an 2d array, exactly an ARR[2][26] using an component, I tried with an NSCollectionView, but I can't add my items, and I don't know if it's suitable for my need.
I need to display this array:
https://postimg.org/image/qvcdgdnkh/
could you give me an adequat way for displaying my array and access easily for each item.
Thank you.

Issue reading .txt file in Matlab. I want to get an array from this file without the unnecessary info it contains

I'm having trouble reading a .txt file to get some data. I want to be able to change some of the values this data contains.
At first, I used this:
A=importdata('myfile.txt');
And got this cell array:
Now what I want is this:
1) Get rid of the headers (the information from cell 1 to 22). That could be easily done by simple indexing (creating a sub-array using just the info from cell 23 to the end of the file).
2) I want to separate the information into different cells, using these identifiers. But I don't know how to separate them into different cells of the array.
'# item bepoch ecode label onset diff dura b_flags a_flags enable bin'
3) Do the same in step 2 to fill those columns with the data in the rest of the cells.
I'm trying to use this approach, but I'm not getting the expected results.
If someone can help me, I'd be glad.
Have you tried dragging the file into the variable workspace window and using the data import wizard? It has some nice features that normally take care of what you are trying to do automatically. Unfortunately, it seems that your text file may have unconventional spacing, but Matlab may be able to handle it if you set the delimeter to ' ' or suchlike.

Loading Matlab matrix into Labview array

I have a matrix which contains GPS waypoints (4 columns - lat,long,h,time) and I would like to use this in a Labview programme to control a UAV.
The code I am working from has a waypoint array to input the waypoints manually from the front panel, but I would like to load this set of points.
I have never used Labview before, so I am having trouble modifying the programme.
Thanks!
Elaborating on a comment, one way that you could do this is to save your MATLAB matrix in a format that you can easily read in LabVIEW, for instance CSV. In MATLAB, save your matrix to a CSV file:
csvwrite(filename, mymat)
where filename is whatever you want it to be surrounded by quotes, e.g. 'GPS_data.csv', and mymat is your data. Then in LabVIEW you can read the contents of the file into a 2D array using Read From Spreadsheet File.vi. Each row of the resulting 2D matrix will a single waypoint, and you can process that data however you see fit. An example that does nothing but display each row after a short delay is shown below.
You could hard-code the filename that you want to read into the Read From Spreadsheet File.vi, or execute your VI without anything wired in to be prompted for a CSV file to read.

creating a character array with gff file

Could someone please help me with creating a "character array" with this sort of data:
ftp://ftp.ncbi.nih.gov/genomes/Bacteria/Escherichia_coli_ATCC_8739_uid58783/NC_010468.gff
Instruction from our collaborator:
One can copy and paste a gff file into a character array by typing gff={} and then copy and “paste excel data”
But I can somehow only save it as a cell array and hence the script downstream can't run properly.
additional info
I need to use the .gff file in a .m script (that I got from someone else) to parse my sequences.
Here's the part of my script that I think pertains to my question:
genelist=gff(:,3);
starts=gff(:,4);
ends=gff(:,5);
names=gff(:,9);
genelogical=strncmp('gene',genelist,4);
Therefore I want 9 columns with information like this:
1. seqID;
2. source;
3. type;
4&5. start and end;
6. score;
7. strand;
8. phase
9. attributes
Also when I saved the cell array as "cell", and tried to convert it into a character array by typing
char(cell)
I got this error message:
cell elements must be character arrays
So guess that doesn't work...
edit over
Anyone has any idea?
Thanks,
Joyce
The instructions you were given are referring to the following context menu item accessible from the "Variables" editor:
First, run at the command line gff={}; to make an empty cell array. Then double click the gff variable in the Workspace tab to get the above editor window. Click on the square regino to the top left of the table to select all cells, then right click to get the displayed menu, and paste the data. You should end up with the following if the paste worked correctly (it could actually take a couple of minutes - check CPU usage):
Then the commands you posted work. The strncmp says definitively that as cell array is needed.

Resources