assign interpolated color bar value to plot

3 visualizzazioni (ultimi 30 giorni)
Samuel Thompson
Samuel Thompson il 3 Nov 2017
Code Extract
My code plots the deflection of a cantilever beam. I wish to change the colour of the deflected shape to correspond to associated stress values from the colourmap.
plot3(A(:,1),A(:,2),A(:,3),'k')
hold on
c=colorbar;
set(c, 'ylim', [min(abs(stress)) max(abs(stress))])
caxis([min(abs(stress)) max(abs(stress))])
for i = 1:length(stress)
plot3(A((2*i)-1:2*i,4),A((2*i)-1:2*i,5),A((2*i)-1:2*i,6))
hold on
end
axis equal
I believe that a solution would involve comparing the stress in the member for the current iteration [stress(i)], with the range of values from the colourmap and subsequently assigning a colour (perhaps in RGB format) that can be included within the plot3 command.
for i = 1:length(stress)
plot3(A((2*i)-1:2*i,4),A((2*i)-1:2*i,5),A((2*i)-1:2*i,6),'%%INSERT APPROPRIATE COLOURMAP VALUE HERE%%)
hold on
end
But I have yet to find a working solution. Any help would be very much appreciated.
Sam!
Note:
  • [stress] = [1x4888] matrix corresponding to the shear stress in each member.
  • Colormap limits comply with stress values
  • for loop plots each member individually (total of 4888)

Risposte (0)

Categorie

Scopri di più su Stress and Strain in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by