How to differentiate the data in excel using a variable?
7 ビュー (過去 30 日間)
古いコメントを表示
Vishnuvardhan Naidu Tanga
2022 年 11 月 18 日
コメント済み: Star Strider
2022 年 11 月 21 日
Hello all,
I am trying to do a differentiation of a variable in excel data with respect to an other variable. For example in my case, the data which has a name in Y in excel has to be differentiated with respect to X. and I need each value after differentiation. Can someone please tell me how can i do it. I am attaching the excel data.
5 件のコメント
Jan
2022 年 11 月 20 日
If you have imported the data already, it is useful to post a small example, how they are represented in Matlab.
You asked for a differentiation at first, but now for an integration. While gradient(x,t) does the first, trapz(x,t) does the second.
採用された回答
Star Strider
2022 年 11 月 20 日
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1198533/matlab.xlsx')
[~,dx] = gradient(T1{:,1:2:end});
[~,dy] = gradient(T1{:,2:2:end});
dydx = dy ./ dx
figure
for k = 1:size(dydx,2)
subplot(4,2,k)
yyaxis left
plot(T1{:,(2*k-1)}, T1{:,(2*k-1)+1})
ylim([0 4])
yyaxis right
plot(T1{:,(2*k-1)}, dydx(:,k))
xlim([0 0.2])
ylim([-40 0])
grid
title(sprintf('X%d,Y%d',[1 1]*k))
end
hl = legend('Data','Derivative');
hs42 = subplot(4,2,8);
hs42.Visible = 'off';
hl.Position = hs42.Position;
% figure % Check First & Last Assignments
% yyaxis left
% plot(T1.X1, T1.Y1, T1.X7, T1.Y7)
% yyaxis right
% plot(T1.X1,dydx(:,1), T1.X7,dydx(:,7))
% grid
This appears to me to be correct. Check it to be certain it produces the desired result.
.
2 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Import from MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!