I'm plotting stress trajectories for simply supported rectangular beam under UDL. Attaching the code and it's output. Help me sort out the error & get correct trajectories.
16 views (last 30 days)
Show older comments
data = readtable('data.xlsx');
%here data is name of excel file from which i'm importing data of x,y grid & principal angles
x = data.x;
y = data.y;
theta1 = data.('Theta1');
theta2 = data.('Theta2');
%% ===== Build structured grid =====
xu = x; % unique x-values
yu = y; % unique y-values
Nx = length(xu);
Ny = length(yu);
% Create 2D mesh
[X, Y] = meshgrid(xu, yu);
size(theta1)
Nx*Ny
%% ===== Reshape angles into matrices =====
Theta1 = reshape(theta1, Ny, Nx); % IMPORTANT: Ny rows, Nx cols
Theta2 = reshape(theta2, Ny, Nx);
%% ===== Compute direction vectors =====
U1 = cos(Theta1); V1 = sin(Theta1);
U2 = cos(Theta2); V2 = sin(Theta2);
%% ===== Create seeding points =====
[startX, startY] = meshgrid( linspace(min(xu),max(xu),8), ...
linspace(min(yu),max(yu),8) );
startX = startX(:);
startY = startY(:);
%% ===== Plot Trajectories =====
figure; hold on;
% Principal direction 1
streamline(X, Y, U1, V1, startX, startY);
% Principal direction 2
streamline(X, Y, U2, V2, startX, startY);
quiver(X, Y, U1, V1, 0.5, 'k'); % direction field (optional)
axis equal tight;
xlabel('X'); ylabel('Y');
title('Stress Trajectories For Simply Supported Steel Beam');
grid on;
3 Comments
Torsten
on 1 Dec 2025
theta1 is 77x1, Nx*Ny equals 5929. No way to reshape because 77*1 doesn't equal 5929 (see above).
Answers (0)
See Also
Categories
Find more on Stress and Strain in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!