MATLAB Answers

Graph of a truss

30 ビュー (過去 30 日間)

回答 (1 件)

John D'Errico
John D'Errico 2021 年 3 月 20 日
Just plot each line segment using line, where you define the end points of the segments. You can provide a color spec for each segment as you wish.
As far as changing from red to blue, What is red in terms of RGB? [it is [1 0 0]. What is blue? it is [0 0 1]. You can choose a value between the two end points simply enough, as
Cred = [1 0 0];
Cblue = [0 0 1];
Cfun = @(t) Cred*t + Cblue*(1-t);
You might want to change that mapping to decide what happens in the interior of the path through color space, but that should suffice. For example, should the mid level go through a mid level gray? Or should it be a vaguely purplish color?
So for any intermediate color based on the parameter t, we would see
Cfun(0)
ans = 1×3
0 0 1
Cfun(1)
ans = 1×3
1 0 0
Cfun(0.25)
ans = 1×3
0.2500 0 0.7500
In your code, you will simply need to transform the stresses you find, something like this:
t = (stress - min(stress))./(max(stress) - min(stress));
The maximum stress will now map to red, the min stress will map to blue.

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by