Computing expint(x), where x is an array, locks up for some x but not others that are very similar
3 次查看(过去 30 天)
显示 更早的评论
Hi all,
I'm computing y = expint(x) where x is an array of doubles. In the attached data, x, there are two very similar arrays of data. Setting column 1 as x, the array y computes instantly. Setting column 2 as x, MATLAB gets stuck (or takes far longer than I'm willing to wait - order minutes). I can obtain the array y from column 2 iteratively, but it is much slower than array computation which will ultimately inhibit its utilization within the parent script.
Thinking the issue is with the values being slightly higher/lower in column 2 than column 1, I attempted the same test with repmat of said higher or lower values. y computed instantly in both instances.
Does anyone have any idea why column 2 does not compute but column 1, repmat(max(column 2),24001,1), and repmat(min(column 2),24001,1) compute without issue?
Thank you in advance.
2 个评论
Walter Roberson
2023-7-26
I do not know why but it has something to do with x2(2124) and x2(23846)
x2(2125:23846) is fast, and x2(2124:23845) is fast, but when both of those endpoints are included, the computation is slow.
I can see nothing at all special about those values. They appear effectively linear in the surrounding data.
采纳的回答
Scott
2023-7-26
2 个评论
John D'Errico
2023-7-26
编辑:John D'Errico
2023-7-26
You won't get MathWorks to fix an issue that was only brought up in Answers. Answers is NOT tech support. Yes, you MIGHT get lucky and someone in the right department might see it. But to quote a well known movie, "Do ya feel lucky, punk?"
Instead, send this in as a question directly to tech support, in this case, as a clear bug. In a quick test, I sorted the second column. Then I sent in the first half of that sorted vector, and then the second half. It works well in both cases. So it looks like a convergence issue, where the tolerance gets screwed up by the too wide range of values in that second column.
In my experience with tech support, you will get a response very quickly, especially for a clear bug.
(Actually, I was going to answer your question until I saw your answer, with a response that said basically what I just said, and told you to send this in as a bug report.)
更多回答(1 个)
Torsten
2023-7-26
编辑:Torsten
2023-7-26
The computation of the second column is even faster. I wonder how matlab evaluates expint(x) if x is a vector different from evaluating the function for each x separately.
fileID = fopen('sampleData.txt','r');
formatSpec = '%f %f';
A = fscanf(fileID,formatSpec);
A = [A(1:2:end),A(2:2:end)];
n = 24001;
tic
for i = 1:n
expint(A(i,1));
end
toc
tic
for i = 1:n
expint(A(i,2));
end
toc
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Manage Products 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!