24小时热门版块排行榜    

查看: 2390  |  回复: 5

blesswj

金虫 (小有名气)


[交流] 【求助】这个MATLAB四维图形如何绘制,请教!!

x=[3.3         0.2         8.9         0.7         1.5         0.0 ]
y=[4.1         0.1         6.6         1.1         2.2         0.0 ]
z=[2.8         0.2         6.9         0.6         5.5         0.1 ]
value=[1.5         0.2         4.2         0.3         21.0         0.1 ]

如何绘制四维图形,请高手指教!!在线等!
回复此楼

» 收录本帖的淘帖专辑推荐

博士以及博后研究!!

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

zzuwangshilei(金币+1): 多谢帮助 2011-03-11 17:04:55
blesswj(金币+10): 谢谢你的工作,varargin表示什么意思?是变量的个数吗?还是什么? 2011-03-12 22:39:45
blesswj(金币+1): 我运行程序的时间出错?你可以帮我在试试吗? 2011-03-12 22:40:27
引用回帖:
Originally posted by blesswj at 2011-03-11 13:19:17:
x=[3.3         0.2         8.9         0.7         1.5         0.0 ]
y=[4.1         0.1         6.6         1.1         2.2         0.0 ]
z=[2.8         0.2         6.9         0.6         5.5         0.1 ]
value=[1.5         0.2         4.2         0.3         21.0         0.1 ]

如何绘制四维图形,请高手指教!!在线等!

将下面的代码保存下来,把你的数据代入即可。
CODE:
function varargout=plot4(x,y,z,c,varargin);

% PLOT4  Plot colored lines and points in 3-D space
%  
%    PLOT3(x,y,z,c), where x, y, z and c are four vectors of the same length N,
%    plots a line in 3-space through the points whose coordinates are the
%    elements of x, y and z, colored occording to the values in c. The line
%    consists of N-1 line segments.
%  
%    Various line types, plot symbols and colors may be obtained with
%    PLOT3(X,Y,Z,s) where s is a 1, 2 or 3 character string made from
%    the characters listed under the PLOT command.
%  
%    Example: A helix:
%  
%        t = 0:pi/50:4*pi;
%        plot4(sin(t),cos(t),t.^2,t,'.-');
%  
%    PLOT4 returns a column vector of handles to lineseries objects, one
%    handle per line segment.
%
%    See also plot, plot3, line, axis, view, mesh, surf.

% author:  Christophe Lauwerys
% contact: christophe.lauwerys@gmail.com
% date:    22/03/2006

error(nargchk(4,inf,nargin))
error(nargoutchk(0,1,nargout))

x=x(:);
y=y(:);
z=z(:);
c=c(:);

% For all c that are NaN, set x to NaN to overcome plotting
idx = find(isnan(c));
x(idx) = NaN;
c(idx) = min(c);

% Interpolate colormap
cmap=colormap; % get current colormap
yy=linspace(min(c),max(c),size(cmap,1)); % Generate range of color indices that map to cmap
cm = interp1(yy,cmap,c,'linear')';

% Plot data
storeNextPlot = get(gca,'NextPlot');
set(gca,'ColorOrder',cm','NextPlot','ReplaceChildren')
h=plot3([x(1:end-1) x(2:end)]',[y(1:end-1) y(2:end)]',[z(1:end-1) z(2:end)]',varargin{:});
set(gca,'NextPlot',storeNextPlot);
if nargout==1, varargout{1}=h; end

2楼2011-03-11 15:19:41
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

信彼南山

木虫 (著名写手)


blesswj(金币+1): 2011-03-12 22:39:52
楼上是超级高手啊
3楼2011-03-11 20:49:43
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
blesswj(金币+1): 2011-03-12 22:40:00
引用回帖:
Originally posted by 信彼南山 at 2011-03-11 20:49:43:
楼上是超级高手啊

惭愧啊!

这是别人的成果,我只是把它分享出来而已。

其实还有更好的处理方式,让两点之间的线颜色也渐变,再进行一些插值就可以了。
4楼2011-03-11 21:21:00
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
blesswj(金币+2): 不知道你试验了没有,是真的不行,我知道这是个简单的函数调用问题,其实我是想问问你函数plot4中的第五个变量varargin是什么意思?不过还是要真诚地谢谢你。 2011-03-13 13:37:12
引用回帖:
Originally posted by blesswj at 2011-03-11 13:19:17:
x=[3.3         0.2         8.9         0.7         1.5         0.0 ]
y=[4.1         0.1         6.6         1.1         2.2         0.0 ]
z=[2.8         0.2         6.9         0.6         5.5         0.1 ]
value=[1.5         0.2         4.2         0.3         21.0         0.1 ]

如何绘制四维图形,请高手指教!!在线等!

真服了你,这么简单的操作,也不懂脑筋想想。
这样子学习是不行的。
CODE:
x=[3.3         0.2         8.9         0.7         1.5         0.0 ]
y=[4.1         0.1         6.6         1.1         2.2         0.0 ]
z=[2.8         0.2         6.9         0.6         5.5         0.1 ]
value=[1.5         0.2         4.2         0.3         21.0         0.1 ]
plot(x,y,z,value)

5楼2011-03-12 23:06:02
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

aibenbenctt

新虫 (初入文坛)



小木虫: 金币+0.5, 给个红包,谢谢回帖
引用回帖:
2楼: Originally posted by xiegangmai at 2011-03-11 15:19:41
将下面的代码保存下来,把你的数据代入即可。
function varargout=plot4(x,y,z,c,varargin);

% PLOT4  Plot colored lines and points in 3-D space
%  
%    PLOT3(x,y,z,c), where x, y, z and c are four ...

不好意思哦。我是新手,想问一下这个varargin是赋值的什么呢
6楼2015-03-25 09:26:02
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 blesswj 的主题更新
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +3 E4V9bALS54sj 2026-09-19 3/150 2026-09-20 01:39 by 9i7PCSZyMzot
[论文投稿] 售SCI文章,我:8O5.5.1.O.54,科目齐全,可+急 +3 E4V9bALS54sj 2026-09-19 3/150 2026-09-20 01:27 by 9i7PCSZyMzot
[公派出国] 售SCI一区T0P文章,我:8O.55.1.O.5.4,科目齐全,可+急 +3 E4V9bALS54sj 2026-09-19 3/150 2026-09-20 01:15 by 9i7PCSZyMzot
[博后之家] 售SCI一区T0P文章,我:8.O.55.1.O.5.4,科目全,可+急 +3 E4V9bALS54sj 2026-09-19 3/150 2026-09-20 01:15 by 9i7PCSZyMzot
[考博] 售SCI文章,我:8O.5.5.1O.54,科目全,可十急 +3 E4V9bALS54sj 2026-09-19 3/150 2026-09-20 01:03 by 9i7PCSZyMzot
[论文投稿] 售SCI文章,我:8O5.5.1.O.54,科目齐全,可+急 +3 E4V9bALS54sj 2026-09-19 3/150 2026-09-20 00:51 by 9i7PCSZyMzot
[考研] 售SCI一区文章,我:8O5.5.1.O5.4,科目全,可伽急 +3 4pRyVGCVerAA 2026-09-19 3/150 2026-09-20 00:15 by 9i7PCSZyMzot
[硕博家园] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +3 4pRyVGCVerAA 2026-09-19 3/150 2026-09-20 00:03 by 9i7PCSZyMzot
[找工作] 售SCI一区T0P文章,我:8.O55.1.O.54,科目全,可十急 +4 4pRyVGCVerAA 2026-09-19 4/200 2026-09-20 00:03 by 9i7PCSZyMzot
[考博] 售SCI一区T0P文章,我:8.O.55.1.O54,科目全,可伽急 +3 4pRyVGCVerAA 2026-09-19 4/200 2026-09-19 23:51 by 9i7PCSZyMzot
[考研] 售SCI一区T0P文章,我:8.O55.1.O.54,科目全,可十急 +3 4pRyVGCVerAA 2026-09-19 4/200 2026-09-19 23:27 by 9i7PCSZyMzot
[论文投稿] 售SCI一区T0P文章,我:8.O.55.1.O54,科目全,可伽急 +3 4pRyVGCVerAA 2026-09-19 4/200 2026-09-19 23:27 by 9i7PCSZyMzot
[公派出国] 售SCI一区T0P文章,我:8.O.55.1.O54,科目全,可伽急 +3 4pRyVGCVerAA 2026-09-19 4/200 2026-09-19 23:03 by 9i7PCSZyMzot
[考博] 售SCI一区T0P文章,我:8.O.55.1.O.54,科目齐全,可+急 +3 4pRyVGCVerAA 2026-09-19 4/200 2026-09-19 23:03 by 9i7PCSZyMzot
[公派出国] 售SCI文章,我:8O5.5.1.O.54,科目齐全,可+急 +3 4pRyVGCVerAA 2026-09-18 7/350 2026-09-19 21:03 by 9i7PCSZyMzot
[教师之家] 现代”学阀”该如何界定 +3 iaeyuan 2026-09-19 3/150 2026-09-19 20:52 by 没昵称呀
[基金申请] 国社科系统bug了,是不是要放榜了? +7 kynobel 2026-09-16 9/450 2026-09-19 14:52 by 接好运婷
[考博] 申博发邮件 +8 Lmengk 2026-09-15 9/450 2026-09-19 09:27 by 中间体超市
[考博] 上海工程技术大学激光智能制造课题组|2027级博士研究生招生公告 +7 水士口 2026-09-16 8/400 2026-09-16 13:47 by kkklens
[考博] 上海工程技术大学激光智能制造课题组招收博士研究生 +8 两三岁ss 2026-09-14 8/400 2026-09-16 09:46 by 水士口
信息提示
请填处理意见