Cell by cell division on portion of array

matlab

    Sponsored Links

    Next

  • 1. Conversion to capital letter
    Hi guys! Is there a way to convert a string in capital letter? Thank you very very much in advance!
  • 2. displaying a string in GUI edit text field
    Hi, I am very new to coding in Matlab and would like to learn how to display a result in a GUI's edit text component. I use the uigetdir control (below) to ask the user for a directory. I want to display the result (folder) in a box on the GUI. function folder = pushbutton4_Callback(hObject, eventdata, handles) folder = uigetdir('C:\Documents and Settings\blah\', 'please pick a data directory') Any help is MORE than appreciated!! Erik
  • 3. [algorithm] Solving equation
    I have a question. a = b * exp(-cx) / (b+x) where a, b, and c are known, and I want to find x value. Is there any function so I can solve this equation? I think the simplest solution is using while() or for() loop by increasing or decreasing x value and find the value which is closest one to 0 by b * exp(-cx) / (b+x) - a. I do not want to use this approach since it requires too much time. Does anyone have an idea on it? Thanks
  • 4. Is there a recommended configuration for a Numbercruncher (Using Parallel computing)
    Hi, could perhaps someone give me a recommendation on what to by for a numbercruncher. I'm thinking of an 8core(2chips) Intel Xeon X5460 at 3.16 GHz?, alternatively an 8core(4chips) Intel Xeon 7130M at 3.2 GHz?. Which operating system is preferable and what are the restrictions regarding Matlab, to get maximum performance. Are these machine configurations fully supported - Does Matlab (current release) use all cores? Thanks for your help
  • 5. Real Time Workshop on Vista
    Hello, I have following problem: I want to build an executable out of a simulink modell via RTW. The process fails at the point where the auto generated batch file is about to run. More precisely the make command cannot be executed. Following error message appears: NMAKE : fatal error U1077: "cmd": R?ckgabe-Code "0x1" This means that the system command "cmd" cannot be found. I figured out that this is due to the restrictions of Windows-Vista and it is not a Matlab problem. If I start a system command window (dos-prompt) as an administator and execute the batch file it works fine! Now the question: is it possible to start Matlab as an administrator? Better, is there a work-around for an ordinary user? The most users in a company don't have admin privileges and still should be able to work with RTW! Thanks a lot in advance, Emmanuel

Cell by cell division on portion of array

Postby Colin Zarzycki » Wed, 15 Apr 2009 08:09:01 GMT

I hope this one's quick and easy; I'm trying to use MATLAB for the first time in a long time...

I have two arrays; one are time dependent measurements at x by y number of gridboxes over a spherical area (monthly data for a year)

size(measurements) = 12  x  y

I have written a few lines that spit out the weighted area for each gridbox.

size(weights) = x  y

I want to do a .* on the x's and y's while keeping the array 12 layered, so then I will have spatial measurements weighted gridbox-by-gridbox (x by y) for 12 monthly periods within the one array.

Sophomore Matlab has failed me-- without running a loop, what's the notation for such an operation?

Thanks.

Re: Cell by cell division on portion of array

Postby Matt Fig » Wed, 15 Apr 2009 13:55:03 GMT

If I understand you correctly, something like this:


A = cat(3,magic(3),magic(3)')
B = toeplitz(1:3)
C = bsxfun(@times,A,B)

Re: Cell by cell division on portion of array

Postby Rajiv Narayan » Wed, 15 Apr 2009 14:10:03 GMT

If you reordered the measurements using permute so that its dimensions are  [x y 12]  you could use bsxfun as Matt suggests:

p=bsxfun(@times, permute(measurements,[2,3,1]), weights)
size(p)
ans= 12 1 1

Re: Cell by cell division on portion of array

Postby Rajiv Narayan » Wed, 15 Apr 2009 20:43:01 GMT

actually that should have read
size(p)
ans= 12 x y

Similar Threads:

1.Changing matrices in cell arrays except for one cell array in a cell

Hey guys I need your help once again! I hope someone can show me how to do this. So I have a cell MTT with "d" cell arrays in it, each cell array contains a matrix of nxn and I need to change a whole row of numbers to Inf in every matrix except for one of them which is going to be given by variable "b". MP is a matrix with a dx2 dimension. Here is my code but this will do it for all matrices, I want to find a way to not do it for "b",

    for d = 1:numMachines;
        MTT{d}(MP(b,2),:) = Inf;
    end

Now I have tried doing the following but I guess I can not do this in MatLab,

    for d = 1:numMachines && d ~= b;
        MTT{d}(MP(b,2),:) = Inf;
    end

Thanks for any help that is given! I hope I made myself clear with my explanation.

2.Auto populate cells based on 2 cells division.

I have a file with two sheets one has a bid template each section of the job 
has a total cost and total days.  I want to be able to chart the totals by 
day.  I need the cells on the sheet with the information for the chart to 
auto fill. Example:	
								
	Cell							A2	Description	Blah Blah					B2	Days	10					C2	Total Cost	100					
	Column A	Column 
B						Days	Cost						1	10						2	10						3	10						4	10						5	10						6	10
	7	10
	8	10
	9	10
	10	10

I want it to auto populate the days in coulmn A based on the total days from 
"B2" on Sheet1. 		
Also divide the daily charge based on "C2" Divided By "B2" from Sheet1

Thanks,
Chance		

3.convert to cell array into a character array or cell array of

Thank you very much Nathan

it works very well, 

Kind Regards, 

Manal

4.convert to cell array into a character array or cell array of strings

Hi

I have this horizontal array of names:
Name                  Size            Bytes  Class    Attributes

  itemNames      1x70             7428  cell               


I need to convert this into a a character array or cell array of strings. 

I tried:

 S = char( itemNames)
??? Error using ==> char
Cell elements must be character arrays.
 
I tried also:

S = cellstr( itemNames)
??? Error using ==> cellstr at 34
Input must be a string.

I appreciate your help, 

thanks, 

Manal

5.delete cells in cell array with certain cell size

Hi there,

how can I delete cells (arrays of different length) with a size==1 in a cell array?

example for an cell array C. Cells 3 and 6 have a size of 1x2 and have to be deleted:
>>C(1:6)
ans = 
    [13x2 single]    [14x2 single]    [1x2 single]    [9x2 single]    [11x2 single]    [1x2 single] 

I could manage it for empty cells using cellfun
% Empty cells in cell arrray will be deleted.
C(cellfun(@(C) isempty(C),C))=[];

Thanks Stephan

6. How to delete row of empty cell arrays without reshaping of cell array

7. Access to cell array in cell array

8. Converting cell array of strings to cell array of numbers



Return to matlab

 

Who is online

Users browsing this forum: No registered users and 76 guest