You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
Limit of a Cell
13 views (last 30 days)
Show older comments
I have a "x1c" cell, and with the following code:
tn=1
for N=1:6591
for t=1:200
k=(((abs(x1c{t,1}(N)-x1c{1,1}(N))).^2))/(6591*200*6)
tn=tn+1;
end
end
I would like to take the "limit of the "k" while t goes infinity"; is it possible?
Accepted Answer
Image Analyst
on 27 Feb 2016
No because you have x1c{t,1} and if t is infinite, then you'd need infinite number of cells in your cell array, which you don't have enough memory for.
18 Comments
Image Analyst
on 27 Feb 2016
Sure, as long as x1c has at least 200 rows.
fert
on 27 Feb 2016
Yes, it has. But when I attempt to do that, in this way:
tn=1
for N=1:6591
for t=1:200
sumx1c{tn}=(((abs(x1c{t,1}(N)-x1c{1,1}(N))).^2))/(6591*200*6);
tn=tn+1;
end
end
sumx1cc=cell2mat(sumx1c);
syms t sumx1cc
limit(sumx1cc,t,200)
it doesn't give any number.
Image Analyst
on 28 Feb 2016
I don't have any optimization toolboxes so I don't know what the limit() function does. Why are you having sumx1c be a cell array when you immediately cast it to a double after the loop. It can be a double right from the start.
We can't try your code conveniently unless you supply us with x1c.
Image Analyst
on 28 Feb 2016
Alright, I made code to create some x1c, made slight modifications to make sumx1c a double array and get rid of unneeded second index, and then ran it, and it ran fine.
% Create some random numbers for x1c
numElements = 6591;
for k = 1 : 300
x1c{k} = rand(1, numElements);
end
% Now do the code.
tn=1
for N=1:6591
for t=1:200
sumx1c(tn)=(((abs(x1c{t}(N)-x1c{1}(N))).^2))/(6591*200*6);
tn=tn+1;
end
end
% Compute the sum array
sumx1cc=sum(sumx1c)
% syms t sumx1cc
% limit(sumx1cc,t,200)
fert
on 28 Feb 2016
Edited: Image Analyst
on 28 Feb 2016
Thank you so much for your effort, and your time. But I want the take the limit, not the sum?
I just want to do this operation:
Image Analyst
on 28 Feb 2016
Edited: Image Analyst
on 28 Feb 2016
You could have saved some wasted effort if you have posted that first. Apparently there are different x functions: an x1, an x2, an x3, etc. So it's best to make x a 2D array with N rows, and like a million or so columns (or some big number). So, to get started we need to know what the various x functions are. What are they? Do you have some equation for the x's?
fert
on 28 Feb 2016
The N is the number of atoms, the t is the time, and the x is the displacement. The x(disp) is not an equation; they have been given as scalar numbers. I suppose my "for loop" meet with the sum in the equation, but as you state, in order to take the limit, I need an equation depends on t in the equation; though I find a matrix contains of the numbers...
I don't have an equation for x's; but the values.
Image Analyst
on 28 Feb 2016
You have x "sub i" as a function of t. In other words, an array x1 as a function of t, and x2 as a function of t, and so on. Can you give me code for creating those? Can we just say N=3 and create 3 random x's, like
x1 = rand(1, 200);
x2 = rand(1, 200);
x3 = rand(1, 200);
If so, we can then get started. Or would you rather give me the code for the x1, x2, and x3?
fert
on 28 Feb 2016
First of all, thank you so much! Absolutely I can give:
This is "x1c":
6591x3 double
6591x3 double
6591x3 double
.
.
.
(200 of them which respect to "t=time")
This is what one of the 6591*3 double includes:
4.80604400000000 5.71385900000000 39.6054360000000
4.21084900000000 5.39276800000000 40.3420780000000
5.10345200000000 4.93471100000000 39.0536430000000
6.80840100000000 4.58005700000000 37.6887870000000
. . .
. . .
. . .
Image Analyst
on 28 Feb 2016
So, x1c{1} is x1, and x1c{2} is x2, and x1c{3} = x3? Is that correct?
Okay, but then why does x1, x2, and x3 have 3 columns instead of 1? According to the formula, x sub n takes one index and a 2D array would take 2 indexes.
Anyway, I still can't run anything because you still haven't given your data. Please attach your x1c as a .mat file or Excel workbook or something.
Image Analyst
on 28 Feb 2016
So clip it to make a smaller one. While you're at it, can you answer my two questions in my last reply?
Image Analyst
on 28 Feb 2016
Perhaps I'll try something later if you you answer my two questions in my earlier reply (third and last chance or I'm moving on).
fert
on 28 Feb 2016
Oh I am so sorry.
So, x1c{1} is x1, and x1c{2} is x2, and x1c{3} = x3? Is that correct?
It is not correct. x1c{1} is a cell which includes 6591 atoms' i j k position directions.
Okay, but then why does x1, x2, and x3 have 3 columns instead of 1? According to the formula, x sub n takes one index and a 2D array would take 2 indexes.
Since it contains both i j k directions.
More Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)