Limit of a Cell
2 次查看(过去 30 天)
显示 更早的评论
fert
2016-2-27
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?
采纳的回答
Image Analyst
2016-2-27
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 个评论
fert
2016-2-27
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
2016-2-28
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
2016-2-28
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
2016-2-28
编辑:Image Analyst
2016-2-28
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
2016-2-28
编辑:Image Analyst
2016-2-28
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
2016-2-28
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
2016-2-28
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
2016-2-28
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
2016-2-28
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.
fert
2016-2-28
In formula it says, for every 6591 atoms, find the difference between positions for different times relative to the time=1.
Because there are three directions for x(i j k).
File exceeds the 5Mb.
Image Analyst
2016-2-28
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
2016-2-28
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
2016-2-28
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)