How to sum a series of functions generated from data

3 ビュー (過去 30 日間)
Jonathan Davidson
Jonathan Davidson 2019 年 4 月 25 日
回答済み: Mark Sherstan 2019 年 4 月 25 日
I have some 2D XRD data in array form(details don't matter).
Essentially I have a list of peak intensities, and miller indices h,k
I wish to plot the paterson function which in this case is
Where u and v are coordinates on the unit mesh.
Converting u,v to x,y and plotting them is straightforward. But I can't seem to get a handle on how to do the summation.
My initial attempt was to define a Paterson function for each individual reflection in my dataset, and then sum them together.
However it seems Matlab isn't happy having u and v defined in the way I have done.
clear all
%define unit mesh
a = 20.46;
b = 9.99;
gamma = 34.12;
%create array
x = [-2*a:1:2*a];
y = [-2*a:1:2*a];
%define u and v
u = x - y*cot(gamma*pi/180);
v = y*csc(gamma*pi/180);
%import data and create Paterson for each reflection
data = csvread('mydata.csv');
for N =1 : size(data,1);
peakn = data(N,1);
F = data(N,2);
h = data(N,3);
k = data(N,4);
Paterson(N,u,v) = F^2*cos(2*pi*(h*u+k*v));
end

採用された回答

Mark Sherstan
Mark Sherstan 2019 年 4 月 25 日
The variable Paterson requires intergers as indices not doubles hence the error. Consider changing that last section as follows:
%import data and create Paterson for each reflection
data = csvread('mydata.csv');
for N =1 : size(data,1);
peakn = data(N,1);
F = data(N,2);
h = data(N,3);
k = data(N,4);
Paterson(N,:) = [u v F^2*cos(2*pi*(h*u+k*v))];
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by