Hello,
could anyone advise me how to make a cylinder from 2D matrix of a number of rows and columns eg x = rand(5,10). And then interpolate values around its perimeter and display it?
Best regards

 Accepted Answer

Matt J
Matt J on 4 Mar 2019
Edited: Matt J on 4 Mar 2019
If you have the Image Processing Toolbox, you would use the warp command, e.g.,
[X,Y,Z] = cylinder(ones(1,5),100);
warp(X,Y,Z,rand(5,10));

4 Comments

It works perfectly, but now I have one more question. How can I change colorbar from B/W to colored (typically RGB) ?
clc; clear all; close all;
[X,Y,Z] = cylinder(ones(1,5),100);
M = round(rand(5,10)*100);
figure
warp(X,Y,Z,M)
colorbar
caxis([0 100]) % rozmezi colorbaru
grid on
This code produce:
c1.PNG
And I want something like this (imagesc) around the cylinder. Exist some function?
c2.PNG
In the documentation for warp, you will see that it has options for providing a colormap or giving RGB data instead of grayscale.
Can't you just call colormap and specify the desired colormap?
colormap(jet)
Ben, thank you.
c3.PNG

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!