Converting FEA data as table into n-D gridded-data Array for Use with 'griddedInterpolant'
显示 更早的评论
I have a dataset represented by table obtained from FE Analyses for flux linkage and i want to process this raw data into proper format through MATLAB scripting (as Look up table), where this raw data conaines parametric sweep

I would like to convert this 4-Colomn table into gridded data set in form of 3D Aarry v=(x,y,z), where x,y,z are the first three colomns and the last colomn is v. then i want to process the data with 'griddedInterpolant' to get finer gidded data. The complete dataset provides all of the information needed to create a gridded data set.
采纳的回答
x=unique(t{:,1}); nx=numel(x);
y=unique(t{:,2}); ny=numel(y);
z=unique(t{:,3}); nz=numel(z);
v=permute( reshape(t{:,4},[ny,nx,nz]) ,[2,1,3]);
F=griddedInterpolant({x,y,z}, v)
8 个评论
Thank you for your comment. that is good soluation. i think the usage of griddedInterpolant is unusful sense we interpolate with the same grid data (x,y,z), right? we might define a new grid and then use this function.
i am trying to plot the results but seems not working, do you have an idea?
f1=figure(1);
surf(x, y, squeeze(v(:,:,end)));hold on;
Thank you for your comment. that is good soluation.
You are quite welcome, but please Accept-click the answer with the green button to indicate so.
i think the usage of griddedInterpolant is unusful sense we interpolate with the same grid data (x,y,z), right?
I think you misunderstand. The code I showed you hasn't done any interpolation yet. If you want to upsample v to a finer, grid (for example 2x in all dimensions), you would do,
x=unique(t{:,1}); nx=numel(x);
y=unique(t{:,2}); ny=numel(y);
z=unique(t{:,3}); nz=numel(z);
v=permute( reshape(t{:,4},[ny,nx,nz]) ,[2,1,3]);
F=griddedInterpolant({x,y,z}, v);
X=linspace(min(x), max(x), 2*nx);
Y=linspace(min(y), max(y), 2*ny);
Z=linspace(min(z), max(z), 2*nz);
V=F({X,Y,Z}) %interpolated v
To plot the the k-th slice of this result as a surface, you would do
surf(X,Y,V(:,:,k)')
Thank you Matt. it worked
but i am wondering why you put ny and then nx in the permute function?
i tryied to exchange between x with y and y with z , but did not work, any idea?
i mean something like this:
v=permute( reshape(t{:,4},[nx,ny,nz]) ,[2,1,3]);
or
v=permute( reshape(t{:,4},[nx,ny,nz]) ,[3,2,1]);
Your table shows that y is the coordinate that changes most quickly as you move through the data, then x, then z
This is because i applied a Parametric sweep run in FEA, but i tryied not to sort the data according to the first colomon, so that the first colomn 'x coordinate' changes most quickly, rather than y coordinate.
i used this code, and the results are in the figured attached
[~, index] = sort(If);
If = If(index);
IPeak = IPeak(index);
Beta = Beta(index);
Landa_d = Landa_d(index);
t{:,1}=If';
t{:,3}=Beta';
t{:,2}=IPeak';
t{:,4}=Landa_d';

do you think this will still not work?
It will work, but you will need,
v=permute( reshape(t{:,4},[nx,nz,ny]) ,[1,3,2]);
since now the y-coordinate varies the slowest.
You could also just presort with,
t=sortrows(t,[3,2,1]);
v=reshape(t{:,4},[nx,ny,nz]);
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
另请参阅
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 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)
