Apply exist on cell array?

I have a 7x1 cell array called X.

exist(X) does not work as I am not allowed to apply it on type cell.
Is there any solution for this problem, please?

Thank you.
Blue
0
bluesaturn (54)
6/11/2010 10:49:51 AM
comp.soft-sys.matlab 207306 articles. 1 followers. lunamoonmoon (258) is leader. Post Follow

2 Replies
1300 Views

Similar Articles

[PageSpeed] 34
"bluesaturn[at]kellnerweg.de" <bluesaturn@kellnerweg.de> wrote in message <774166218.318291.1276271421713.JavaMail.root@gallium.mathforum.org>...
> I have a 7x1 cell array called X.
> 
> exist(X) does not work as I am not allowed to apply it on type cell.
> Is there any solution for this problem, please?
> 
> Thank you.
> Blue

Hi Blue, you have to include the name of the variable, be it a cell array or not,  in single quotes.

A = cell(2,1);
exist('A')

Hope that helps,
Wayne
0
Wayne
6/11/2010 4:13:04 PM
Wayne King wrote:
> "bluesaturn[at]kellnerweg.de" <bluesaturn@kellnerweg.de> wrote in 
> message 
> <774166218.318291.1276271421713.JavaMail.root@gallium.mathforum.org>...
>> I have a 7x1 cell array called X.
>>
>> exist(X) does not work as I am not allowed to apply it on type cell.
>> Is there any solution for this problem, please?
>>
>> Thank you.
>> Blue
> 
> Hi Blue, you have to include the name of the variable, be it a cell 
> array or not,  in single quotes.
> 
> A = cell(2,1);
> exist('A')
> 
> Hope that helps,


To which I would add that unless you have specific reason not to, you should use

exist('A','var')

just in case your variable name happens to be the same as the name of a 
function or the like.
0
Walter
6/11/2010 4:25:36 PM
Reply:
Similar Artilces:

Patch - Applying a .diff file
I am trying to apply a patch to a tource tarball I have a source tar file checkpw_1.00.orig.tar and a corresponding patch file checkpw_1.00-3.diff Here is what is happening: mark@venus:/u/dev01/checkpw$ ls checkpw_1.00-3.diff checkpw_1.00.orig.tar mark@venus:/u/dev01/checkpw$ patch checkpw_1.00.orig.tar checkpw_1.00-3.diff patching file checkpw_1.00.orig.tar patching file run patching file errno.diff patching file changelog patching file checkapoppw.8 patching file checkpw.8 patching file checkpw.README.Debian patching file checkpw.docs patching file checkpw.examples patching file control ...

Simple Array Transformation
Hallo, I have a signal vector 'sig1'. There are 2 kinds of signals '1' and '-1' otherwise no signal '0'. I would like to transform 'sig1' vector to 'sig2' vector like this: each row with signal '1' in 'sig1' should be transfered in 'k' rows with signal '1' in 'sig2'. The same with signal '-1' with value '-1'. I tried this: dur = 3; sig1 = [0 0 1 0 0 0 0 -1 0 0 0 0 0 1 0 0 0 0 -1 0 0 ]'; sig2 = zeros(size(sig1,1),1); sig2(find(sig1(:,1)==1):find(sig1(:,1)==1)+dur) = 1; sig2(find(sig...

Adding point by point using a cell matrix
I have a cell matrix that is 4x3. Each of the contents is 150x1...so I have something like this: [150x1 double] [150x1 double] [150x1 double] [150x1 double] [150x1 double] [150x1 double] [150x1 double] [150x1 double] [150x1 double] [150x1 double] [150x1 double] [150x1 double] I would like to add point by point along the rows for each cell and then take the mean of the added rows, OR better yet, just take the point by point mean of each row such that I end up with a new cell that is 1x3. Something like this: [150x1 double] [150x...

How to sort array from left to right columns one by one?
Hi, Could any one help me to sort an array from left column to right as foolows: a = [ 3 4 5; 2 2 5; 3 1 2; 3 4 4; 2 4 2] the sorted array will be as follows: sorteda = [2 2 5; 2 4 2; 3 1 2; 3 4 4; 3 4 5] The sort procedure should be as follows: Step 1: sort array according to first column Step 2: sort array according to second column, but without change the order of the first column Step 3: sort array according to third column, but without change the order of the first two columns Step 4: ... Thanks in adv...

Test for dialog existence
Hi. Can anyone suggest how to test for the existence of a dialog? In the example below a dialog is created containing a plot which can be modified. However it seems to be difficult to test whether the dialog has been closed. This creates the dialog: BeginPackage["TestExample`TestDialog`"]; CreateTestDialog::usage = "CreateTestDialog[] creates a test dialog"; Begin["`Private`"]; CreateTestDialog[] := Module[{}, n = 4; CreateDialog[ plot = Dynamic[ ParametricPlot[{Sin[t], Sin[n t]}, {t, 0, 2 Pi}, Ticks -> None, ImageSize ...

initializing an array in ksh
Hello all I can't believe I'm asking this, but for some reason i can't figure out why this doesn't work. I'm trying to initialize an array with the values from a list which contains all the files in a directory. What i would like is to have one file/Directory in each element of the array. I tried the following but it doesn't work: 1. list=`ls /path/to/directory` 2. set -A files "$list" 3. echo "number of files is ${#files[*]} 4. echo "file #1 is ${files[1]}" the output is: 5. number of files is 1 # there are more than 1 files in the director...

Splinter Cell Double Agent Help!
I am on the map with the cruise ship. I have made it to what seems to be the bridge of the ship. There are stairs from an upper deck leading down to the bridge. I am always noticed no matter where I hide. I can remain perfectly still, completely hidden from view, but once the two dudes on the bridge go up the stairs (where I came from), they always notice me and search for me. Then the dude patrolling outside the bridge always comes in and walks directly towards me no matter where I'm at. I can never escape from there. Any suggestions? >I am on the map with the cruise ship. I...

Changing the Background Color for One Cell in a JTable
I've been working on this for a few hours. I've read tutorials and seendifferent examples, but this is still driving me nuts.I have a table and want to be able to change the color of one cell in it. It seems to do this, I can't get a cell renderer and just change the color,I have to create my own class to do that. I've tried that and a number ofother things and can't get it to work.I finally took the SimpleTableDemo from Sun and checked to make sure it wasrunning. Once it was, I added four lines: boolean isSelected = table.isCellSelected(1, 1); DefaultTable...

how can one index into a cell array of structs?
I am trying to produce a map of climate values that are stored in a cell array of structures. For example, from the cell array {}Clim<79x133>, I can retrieve all of a single cell's maximum temperatures (which is a 13680x1 double) with: Clim{1,1}.tmax This command gives me all 13680 maximum temperature values from the element tmax. I need to grab a single value for that element for all cells in the array (let's say the last value, number 13680 from all cells)... I have tried things like Clim{:,:}.tmax(1360,:) to no avail... Can anyone suggest an approach? Th...

assigning random numbers to an already existing matrix of variables
Hi, I have a randomly generated matrix (of patients) and I'd like to assign each of them a random number between [0,1], which would define some sort of a disease index for that patient. How would I be able to do this? thanks! "Priyanka " <priyanka.kanth@stanford.edu> wrote in message <lsghh7$3q0$1@newscl01ah.mathworks.com>... > Hi, > > I have a randomly generated matrix (of patients) and I'd like to assign each of them a random number between [0,1], which would define some sort of a disease index for that patient. How would I be able to do t...

Named index on an array
Hi, Is there a way to code named index on an array in RPG ILE (V5R4)? Instead of having myArray(1), myArray(2), etc.. I would like something like: myVar = 'ABC' myArray(myVar) where 'ABC' (the content of myVar) is used as the index. Thx Jack On Mar 7, 10:59=A0am, Jack <jacquestar...@gmail.com> wrote: > Hi, > > Is there a way to code named index on an array in RPG ILE (V5R4)? > > Instead of having myArray(1), myArray(2), etc.. I would like something > like: > > myVar =3D 'ABC' > myArray(myVar) where 'ABC' (the content of myV...

populate second listbox with array data based on choice of first listbox
Currently this second listbox just contains numbers 1..100. and is populated automatically with the filler array @list2. The first listbox contains the state abbreviations. What I think that I want to do is create 51 arrays, 1 for each state with the county names. Then based on the choice in the first listbox, say AK (Alaska) is chosen, then populate listbox2 with the contents of array @AK, if AL (Alabama) is chosen then populate with array @AL, and so on. I am having trouble even getting my mind around the logic of this, much less the algorythm and code. Any help appreciated. ...

apply a math function to alist of numbers
if I have a tcl list of numbers, what would be the fastest way to apply a math function to each element ? mitch <mitchu@houston.rr.com> wrote: > if I have a tcl list of numbers, what would be the fastest way to apply > a math function to each element ? Be more specific. What do you mean by "apply a math function to each element"? Do you want to add them all up and return the sum, do you want to replace each element by the result of the function, or something else entirely? And why do you want to know the "fastest" way? It's possible that there&...

Can SliceThickness(0x0018, 0x0050) be counted on to exist?
Hello, I have an MR DICOM dataset- if I am currently looking at an image, and I want to consider pixels 5mm into the dataset from the current image, can I just use the position info in ImagePosition(Patient) to figure how many slices I need to look at to traverse that distance of 5mm? Or is there anything else I must take into account? ...

Trimming the content of a cell
X={'00078210X';'00079410X';'00086T103';} is there a way to select only the first 6 characters using a matlab function to make it X= {'000782';'000794';'00086T';} Thanks This could be done using REGEXP (and cousins), but cellfun works too: X={'00078210X';'00079410X';'00086T103'} X = cellfun(@(x) x(1:6),X,'Un',0) if I have doubles what is the alternative function to cellfun that would help me in trimming the numbers. example X= [1234567] how can I trim it to X=[123 ]; ...

Generate dictionary with the help of two array
Hi Folks I have two array keyArr = [@"name",@"city",@"street"] valueArr = [@"Bob",@"Newyork",@"dallas"] addDict = {@"name":@"Bob",@"city":@"Newyork",@"street":@"dallas"} Thanks for your all help.. IPhone Lover <iphone.objcode@gmail.com>, on 15/09/2010 10:35:03, wrote: [subject is: "Generate dictionary with the help of two array" please state your questions in the body of your message] > Hi Folks > > I have two array > > keyArr =...

Asserting existing key to be primary
I have a table that has a candidate primary key (e.g. - unique, not null) that I wish to actually assert _is_ a primary key. Is there a way to do that without too much (mwahahhaha! fiddling with pg_class!!!) trickery? -- (format nil "~S@~S" "cbbrowne" "acm.org") http://cbbrowne.com/info/emacs.html "What we need is either less corruption, or more chance to participate in it." -- Unknown Chris Browne <cbbrowne@acm.org> writes: > I have a table that has a candidate primary key (e.g. - unique, not > null) that I wish to actually a...

Replicate Cells
How do I create the following cell: a={{1} {2} {2} {2} ... {2} {2} {2} {1}}; That is, I want to replicate the "{2}" many times. I'd like to do this within a single command line if possible. Jack Sharer wrote: > > > How do I create the following cell: > a={{1} {2} {2} {2} ... {2} {2} {2} {1}}; > That is, I want to replicate the "{2}" many times. > I'd like to do this within a single command line if possible. N = 10 ; a = { {1} repmat({{2}},1,N) {1} } ; Are you sure you want each element of the cell array to be a cell array itself? Jos "Ja...

How is it applied?
<p><font size="+2"><!--y1miz82a9g9--><b>Intr<!--1uv3a72kf8u7q-->odu<!--d0ip4m2isr-->cin<!--kgh1ew4d4t62wp-->g VP-<!--vw8djf1dpydci8-->RX p<!--s0r93ub5fdfb3-->en<!--xup1io19v39y-->is en<!--tiy7h2288n2ci2-->large<!--vtmtbq1uxfa93-->me<!--or6e9e2s5l-->nt pi<!--tzbji87s3rd9-->lls</b></font></p> <p><font size="+1">Ga<!--3t0jjy1czbqni-->in 3+ in<!--2ymo603wpzfc-->che<!--zb06o125zzq7-->s in l<!--vun9yb1bm5-->eng<!--m6eff71kryo1y-->th<...

reshaping array
Hello, I have an array: A=['A1' 'A2' 'A3' 'A4' 'A5' 'A6' 'A7' 'A8' ] want to create another array B=['A2A1' 'A4A3' 'A6A5' 'A8A7'] is it possible to do this with the reshape command?. If not how to implement this? On 2/3/2012 12:11 PM, Leyo Joseph wrote: > Hello, > > I have an array: > > A=['A1' 'A2' 'A3' 'A4' 'A5' 'A6' 'A7' 'A8' ] > want to create another array B=['A2A1' 'A4A3' 'A6A5&...

Applying Apply
Can anyone suggest an elegant way to apply a function - in this case a Style - to elements in a list. In the example below I'm applying colours to their names. (I don't know how Text is being used so I aimed to preserve the original structure). As you can see it took me two lines to splice in the colour styles. I thought I should have been able to do it in one, but couldn't figure out how. plabel = {Text["Orange", {10, 44}], Text["Blue", {10, 50}], Text["Green", {2, 99}], Text["Red", {2, 20}]}; textColours = {Orange, Blue, Gr...

Keeping an Array in Memory
I'm afraid I don't know PHP well enough to figure this out. What I would like is to keep an array in memory so that it doesn't have to be reloaded each time a .php script is run. Is this possible? In Java, I could load the array from a file in the init() method of a servlet and it would stay in memory until the server is shutdown or restarted, etc. Thanks, Andrew Hi Andrew, what do you mean "reloaded"? Anyways... you can use sessions or simple cookies. read some tutorials (google) what sessions in php are and how they work if you don't know yet (as i would...

Swap even/odd elements in array
Hi All, sorry if the question is trivial: how could I swap even and odd elements of a 1-D 16-bit INT array without using loops? That is, if the source array is [a0,a1,a2,a3,..] I want it to be [a1,a0,a3,a2,..] Thanks! In article <1119428174.330105.170110@o13g2000cwo.googlegroups.com>, photosalex@freenetname.co.uk wrote: > Hi All, > sorry if the question is trivial: > how could I swap even and odd elements of a 1-D 16-bit INT array > without using loops? That is, if the source array is > > [a0,a1,a2,a3,..] > > I want it to be > > [a1,a0,a3,a2,.....

apply and or
Hi, I have just started learning Scheme, and have a (probably simple) question. I have a list of boolean values, and I would like to test if any of them are true. If or was a procedure, I could simply say (apply or list-of-booleans) But as or is a macro, this doesn't work. I ended up writing (define list-or (lambda (l) (let recor ((ll l)) (if (null? ll) #f (if (car ll) #t (recor (cdr ll))))))) which solves the problem, eg (list-or list-of-booleans). This was good practice, but I would like to know if there is a general way to apply a macro on a list. Thanks, Tamas Ta...

which cells are numeric?
Using R2012b, I have a cell array, let's call it c. It looks like this c = {1,2,3,'four',5,6,7,8,9}; how can I create d, which is a logical array that looks like d = (1,1,1,0,1,1,1,1,1); If I do isnumeric(cell2mat(c(3))), it returns 1, as expected if I do isnumeric(cell2mat(c(4))), it returns 0, also as expected so I figured I could use cellfun in some fashion, to do what I want, but d = isnumeric(cellfun(@cell2mat,c)) fails with >Cell contents reference from a non-cell array object. > >Error in cell2mat (line 37) > if isnumeric(c{1}) || ischa...