フィルターのクリア

Plotting data against a combination array

3 ビュー (過去 30 日間)
Raymond Elliott
Raymond Elliott 2023 年 10 月 26 日
コメント済み: Raymond Elliott 2023 年 10 月 27 日
I have created a combination array of two vectors ranging from -60 to +60 with increments of 1. I am assigning the first column of the combination matrix to X and the second column to Y. I am then looping through every combination of this array, and using the X and Y values to output my Z value, so for every unique combination of X and Y, I have a unique value for Z. I have tried doing a 3D plot, but am running into issues with the X and Y parameters because they are not linear. Any help is greatly appreciated!
alpha = 0;
L = 0.002;
W = 0.002;
x = 0;
y = 0;
h = 0.001;
thetaX_loop = -60:1:60;
thetaY_loop = -60:1:60;
combo = table2array(combinations(thetaX_loop,thetaY_loop));
Z = zeros(length(combo),4);
for i = 1:length(combo)
X = combo(i,1);
Y = combo(i,2);
deltaX = tand(thetaX)*cosd(alpha)*h;
deltaY = tand(thetaY)*cosd(alpha)*h;
A1 = (W-x-deltaX)*(L-y-deltaY);
A2 = (W+x+deltaX)*(L-y-deltaY);
A3 = (W-x-deltaX)*(L+y+deltaY);
A4 = (W+x+deltaX)*(L+y+deltaY);
Em = cosd(thetaX)*cosd(thetaY);
Z1 = A1*Em;
Z2 = A2*Em;
Z3 = A3*Em;
Z4 = A4*Em;
Z_tot = [Z1,Z2,Z3,Z4];
Z(i,:) = Z_tot;
end

採用された回答

Walter Roberson
Walter Roberson 2023 年 10 月 26 日
alpha = 0;
L = 0.002;
W = 0.002;
x = 0;
y = 0;
h = 0.001;
thetaX_loop = -60:1:60;
thetaY_loop = -60:1:60;
[thetaX, thetaY] = ndgrid(thetaX_loop,thetaY_loop);
deltaX = tand(thetaX).*cosd(alpha)*h;
deltaY = tand(thetaY).*cosd(alpha)*h;
A1 = (W-x-deltaX).*(L-y-deltaY);
A2 = (W+x+deltaX).*(L-y-deltaY);
A3 = (W-x-deltaX).*(L+y+deltaY);
A4 = -(W+x+deltaX).*(L+y+deltaY);
Em = cosd(thetaX).*cosd(thetaY);
Z1 = A1.*Em;
Z2 = A2.*Em;
Z3 = A3.*Em;
Z4 = A4.*Em;
tiledlayout('flow');
nexttile(); surf(thetaX, thetaY, Z1, 'edgecolor', 'none'); colorbar(); title('Z1'); xlabel('{\theta}X'); ylabel('{\theta}Y');
nexttile(); surf(thetaX, thetaY, Z2, 'edgecolor', 'none'); colorbar(); title('Z2'); xlabel('{\theta}X'); ylabel('{\theta}Y');
nexttile(); surf(thetaX, thetaY, Z3, 'edgecolor', 'none'); colorbar(); title('Z3'); xlabel('{\theta}X'); ylabel('{\theta}Y');
nexttile(); surf(thetaX, thetaY, Z4, 'edgecolor', 'none'); colorbar(); title('Z4'); xlabel('{\theta}X'); ylabel('{\theta}Y');
  1 件のコメント
Raymond Elliott
Raymond Elliott 2023 年 10 月 27 日
Thank you so much this is exactly what I was looking for! :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by