Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: cell array dimensions do not match
Replies: 4   Last Post: Dec 12, 2012 10:42 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
bartekltg

Posts: 31
Registered: 12/11/12
Re: cell array dimensions do not match
Posted: Dec 12, 2012 6:41 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

W dniu 2012-12-13 00:21, Alex pisze:
> I am having a problem where I am trying to create a cell array of

So try cell array:)

> strings to use in rmfield. I am combining a stem(chart) with a number
> (any number) to create the field I want to remove. For example, if I
> need to remove DeltaT.chart1, deltaT.chart6, deltaT.chart7, then my cell
> array would be:
> chart1
> chart6
> chart7
>
> The problem I have is when I get to chart 10 or more. If I have a
> number greater than 10 I would have the following:
> chart1
> chart6
> chart7
> chart10
> and I get the error ??? Error using ==> vertcat
> CAT arguments dimensions are not consistent.
>
> Error in ==> remover at 28
> toremove = [toremove;field]




>> A=['chart1';'chart6';'chart7'];
>> whos A


Name Size Bytes Class Attributes

A 3x6 36 char



> I think because I am trying to fit a 7 character wide (chart10) string
> into a 6 character wide cell array.


This isn't cell array!

> Is there a way around this or something I can do instead? My code is
> below if it helps.
>
>
> for a = 17%1:22
> listremove = []
> toremove = []


toremove = {}

> rmvr = 0;
> Fileone = 'NODIPSinBTBTB_Delta';
> File = [Fileone,'Comp',int2str(a)]
> load([Fileone,int2str(a),'.mat'])
> data = deltaT;
> stem = 'chart';
> for L = 1:length(fieldnames(data))
> field = [stem,int2str(L)];
> if length(data.(field)) == 0
> rmvr = 1
> listremove = [listremove L];
> end
> end
> if rmvr == 1
> for g = 1:length(listremove)
> field = [stem,int2str(listremove(g))]

toremove = [toremove;field]

toremove = { toremove;field }

> end
> deltaT = rmfield(data, toremove)
> end
> save(File, 'deltaT')
> clear all
>
> end


>> A={'chart1';'chart6';'chart7'; 'chart10'}

A =

'chart1'
'chart6'
'chart7'
'chart10'

>> whos A
Name Size Bytes Class Attributes

A 4x1 498 cell


bartekltg






Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.