extract the title from a cell array? - matlab

how can I extract the title from a cell array?
example :
for ii=1: nc
figure( h(ii) )
subplot( r,c,n(j) )
bar(B,FF) %<== istogramma
title('Istogramma Elemento',txt(1,2)); <==Istogramma Elemento : As
end
I should write a routine in which they are created 4 figures.
within each figure are put 4 histograms. For each histogram changes the title.
the normal size of the matrix is of type 31x15
1 2 3 4
'N° sul terreno' 'As ppm' 'Be ppm' 'Cd ppm'
'C26' '' '' ''
'C23' '' '' ''
'C19' '' '' ''
'C11' '' '' ''
'C27' '' '' ''
'C24' '' '' ''
'C21' '' '' ''

Related

DB2 SQL Query Filtering rows based on multiple fields

I need to write a query based on the following conditions:
Within one table, the following condition must be met:
table name: DLS_RBM_RBI
columns within the table
RBM_3_CD must be blank
If RBM_3_CD is blank, then RBM_2_CD must be 1
If RBM_3_CD is blank and RBM_2_CD is blank, then RBM_1_CD must be 1
How would these conditions be coded in a SQL statement? In an IF within a where clause or case in a select?
I tried using a where clause with these conditions.
AND (D.RBM_3_CD = '')
OR (D.RBM_3_CD = '' AND D.RBM_2_CD = '1')
OR (D.RBM_3_CD = '' AND RBM_2_CD = '' AND RBM_1_CD = '1')
The first statement
AND (D.RBM_3_CD = ' ')
negates the need for the second and third. There's no way for the first statement to false while the second or third are true.
try this instead
where D.RBM_3_CD = ' '
and ( (D.RBM_3_CD = '' AND D.RBM_2_CD = '1')
or (D.RBM_3_CD = '' AND RBM_2_CD = '' AND RBM_1_CD = '1')
)

Get serial date numbers from datenum in MATLAB from an input cell array

From reading in this Excel file into MATLAB
[frates, fdlable] = xlsread('C:\Users\Nancy\Documents\Research\Data\USTreasury\USTreasuryDataset\FredTreasuryRatesMon','A8:X818')
I get a cell array rates fdlable1 811 by 12 of Excel dates, format m/d/yyyy that I want convert to serial date numbers through datenum
Must I convert fdlable1 'm/d/yyyy' to a string variable first before using datenum?
Here the assignment fails because there are empty cells in fdlable1:
date_num = cellfun(#datenum, fdlable1, 'UniformOutput', false);
Warning: Usage of DATENUM with empty date character vectors or empty strings is not supported.
Results may change in future versions.
fdlable1 =fdlable(:,1:2:23); 811 x 12 from 811 x 23
fdlable:
'7/1/1954' '' '7/1/2001' '' '1/1/1934' '' '12/1/1958'
'8/1/1954' '' '8/1/2001' '' '2/1/1934' '' '1/1/1959'
'9/1/1954' '' '9/1/2001' '' '3/1/1934' '' '2/1/1959'
'10/1/1954' '' '10/1/2001' '' '4/1/1934' '' '3/1/1959'
'11/1/1954' '' '11/1/2001' '' '5/1/1934' '' '4/1/1959'
'12/1/1954' '' '12/1/2001' '' '6/1/1934' '' '5/1/1959'
'1/1/1955' '' '1/1/2002' '' '7/1/1934' '' '6/1/1959'
'2/1/1955' '' '2/1/2002' '' '8/1/1934' '' '7/1/1959'
'3/1/1955' '' '3/1/2002' '' '9/1/1934' '' '8/1/1959'
'4/1/1955' '' '4/1/2002' '' '10/1/1934' '' '9/1/1959'
'5/1/1955' '' '5/1/2002' '' '11/1/1934' '' '10/1/1959'
'6/1/1955' '' '6/1/2002' '' '12/1/1934' '' '11/1/1959'
'7/1/1955' '' '7/1/2002' '' '1/1/1935' '' '12/1/1959'
'8/1/1955' '' '8/1/2002' '' '2/1/1935' '' '1/1/1960'
fdlable1:
'7/1/1954' '7/1/2001' '1/1/1934' '12/1/1958' '7/1/1959' '4/1/1953'
'8/1/1954' '8/1/2001' '2/1/1934' '1/1/1959' '8/1/1959' '5/1/1953'
'9/1/1954' '9/1/2001' '3/1/1934' '2/1/1959' '9/1/1959' '6/1/1953'
'10/1/1954' '10/1/2001' '4/1/1934' '3/1/1959' '10/1/1959' '7/1/1953'
'11/1/1954' '11/1/2001' '5/1/1934' '4/1/1959' '11/1/1959' '8/1/1953'
'12/1/1954' '12/1/2001' '6/1/1934' '5/1/1959' '12/1/1959' '9/1/1953'
'1/1/1955' '1/1/2002' '7/1/1934' '6/1/1959' '1/1/1960' '10/1/1953'
'2/1/1955' '2/1/2002' '8/1/1934' '7/1/1959' '2/1/1960' '11/1/1953'
'3/1/1955' '3/1/2002' '9/1/1934' '8/1/1959' '3/1/1960' '12/1/1953'
'4/1/1955' '4/1/2002' '10/1/1934' '9/1/1959' '4/1/1960' '1/1/1954'
How to get a matrix of serial date numbers?
The corresponding variable rates is:
**rates = frates(:,1:2:23); 811 x 12**
0.800000000000000 3.61000000000000 0.720000000000000 3.01000000000000
1.22000000000000 3.48000000000000 0.620000000000000 3.09000000000000
1.07000000000000 2.63000000000000 0.240000000000000 3.13000000000000
0.850000000000000 2.24000000000000 0.150000000000000 3.13000000000000
0.830000000000000 1.96000000000000 0.160000000000000 3.27000000000000
1.28000000000000 1.69000000000000 0.150000000000000 3.33000000000000
1.39000000000000 1.65000000000000 0.150000000000000 3.52000000000000
1.29000000000000 1.70000000000000 0.190000000000000 3.82000000000000
1.35000000000000 1.75000000000000 0.210000000000000 3.87000000000000
1.43000000000000 1.69000000000000 0.270000000000000 4.70000000000000

How to disable "heading" for all firebird subrequests

I have a request for firebird with concatenation and using nested select and list (), and then written this to the file. The first command is SET HEADING OFF;
SET HEADING OFF;
SELECT DISTINCT '"' || REPLACE(TRIM(COALESCE(x.column, '')), '"', '""')
|| '"; "' || REPLACE(TRIM(COALESCE(x.column2, '')), '"', '""')
|| '"; "' || REPLACE(TRIM(COALESCE(list(DISTINCT x.column3, ','), '')), '"', '""')
|| '";'
FROM (
SELECT ycolumn AS column, ycolumn1 AS column1, ycolumn2 AS column2, list(DISTINCT ycolumn3, ',') AS column3
FROM (
SELECT d.column AS ycolumn, c.column1 AS ycolumn1, dc.column2 AS ycolumn2, ws.column3 AS ycolumn3
FROM ...
)y
GROUP BY ycolumn, ycolumn1, ycolumn2
) x
GROUP BY x.column, x.column1, x.column3
;
The problem is that the headers for the nested SELECTs are not disabled and outputs file is like this:
==============================================================================
0:218
==============================================================================
CONCATENATION:
"field"; "field1"; "field2"; "field3";
Is it possible to disable headers for all requests?
The problem is that LIST produces a BLOB SUB_TYPE TEXT, and ISQL defaults to using configuration BLOBDISPLAY set to 1 (to show BLOB SUB_TYPE TEXT). With this setting, ISQL will automatically output all text blobs inline per row, but to discern which blob is which, it will include the column alias when showing the blob content.
You could turn off blobdisplay using SET BLOBDISPLAY OFF, but then your query result will only show the blob-id and not the blob content which is probably not what you want. For the query in your question it would only show:
0:218
The alternative is to cast the query to a VARCHAR of sufficient size:
SELECT DISTINCT cast('"' || REPLACE(TRIM(COALESCE(x.column, '')), '"', '""')
|| '"; "' || REPLACE(TRIM(COALESCE(x.column2, '')), '"', '""')
|| '"; "' || REPLACE(TRIM(COALESCE(list(DISTINCT x.column3, ','), '')), '"', '""')
|| '";' as varchar(8191))
FROM ...
Max VARCHAR size is 8191 for character set UTF8, or 32765 for a single byte character set, but there are additional constraints to row length (maximum 64KB total).

Remove any spaces between ' ' in cell array Matlab

I have this cell array
aitransp =
Columns 1 through 14
'27' '26' '25' '24' '23' '22' '21' '20' '19' '18' '17' '16' '15' '14'
Columns 15 through 21
'13' '12' '11' ' 9' ' 8' ' 7' ' 1'
As you can see, the last 4 elements have a space between the ' ', such as ' 9'.
Is there any way to remove any spaces occurring between '' in a cell array?
Thanks in advance..
Just use strtrim, you don't have to convert to string
strtrim(aitransp)
You can use regular expressions for greater flexibility:
result = regexprep(aitrasp, '(^\s*)' , ''); %// remove only leading space
result = regexprep(aitrasp, '(^\s*)|(\s*$)' , ''); %// remove leading or trailing space
result = regexprep(aitrasp, '\s' , ''); %// remove any space
for ii = 1:numel(aitransp)
aitransp{ii}(aitransp{ii} == ' ') = '';
end
This should do the trick.

white space in cell array

I am using textscan to read text file and I get <55x1 cell>
examples:
'aa a aa'
'a aaaa a'
'a = aaaaa'
'aaaaaa'
' a a a aaa'
'aa'
'aaa'
'aaaa'
.
.
.
.
I want to delete the white spaces in each sting
If I have a sting
string = 'I am 24 Years old'
And I use
string(ismember(string,' ')) = [];
it will eliminate the spaces and I will get
'Iam24Yearsold'
But with the cell doesn't work or I don't know how to do it
How can I do that? any suggestions please?
You can use strrep:
a = { 'aa a aa'
'a aaaa a'
'a = aaaaa'
'aaaaaa'
' a a a aaa'
'aa'
'aaa'
'aaaa'
'I am 24 Years old'};
strrep(a, ' ', '')
This results in
ans =
'aaaaa'
'aaaaaa'
'a=aaaaa'
'aaaaaa'
'aaaaaa'
'aa'
'aaa'
'aaaa'
'Iam24Yearsold'