1300 1

MATLAB课程:代码示例之Graphics and Visualization(四) [推广有奖]

企业贵宾

已卖:160份资源

巨擘

0%

还不是VIP/贵宾

-

威望
4
论坛币
624047 个
通用积分
180.5582
学术水平
918 点
热心指数
987 点
信用等级
841 点
经验
399203 点
帖子
9786
精华
48
在线时间
17322 小时
注册时间
2014-8-19
最后登录
2022-11-2

楼主
widen我的世界 学生认证  发表于 2016-3-8 14:53:50 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

MATLAB课程:代码示例之Graphics and Visualization(四)


Visualizing Four-Dimensional Data


This example shows several techniques to visualize four dimensional (4-D) data in MATLAB®.


Visualize 4-D Data with One Discrete Variable

Sometimes data has a variable which is discrete with only a few possible values. You can create multiple plots of the same type for data in each discrete group. For example, use thestem3 function to see the relationship between three variables where the fourth variable divides the population into discrete groups.

load patients Smoker Age Weight Systolic                           % load datansIdx = Smoker == 0;smIdx = Smoker == 1;figurestem3(Age(nsIdx), Weight(nsIdx), Systolic(nsIdx), 'Color', 'b')    % stem plot for non-smokershold onstem3(Age(smIdx), Weight(smIdx), Systolic(smIdx), 'Color', 'r')    % stem plot for smokershold offview(-60,15)zlim([100 140])xlabel('Age')                                                      % add labels and a legendylabel('Weight')zlabel('Systolic Blood Pressure')legend('Non-Smoker', 'Smoker', 'Location', 'NorthWest')


Visualize 4-D Data with Multiple Plots

With a large data set you might want to see if individual variables are correlated. You can use the plotmatrix function to create an n by n matrix of plots to see the pair-wise relationships between the variables. The plotmatrix function returns two outputs. The first output is a matrix of the line objects used in the scatter plots. The second is a matrix of the axes objects that are created.

The plotmatrix function can also be used for higher order data sets.

load patients Height Weight Diastolic Systolic    % load datalabels = {'Height' 'Weight' 'Diastolic' 'Systolic'};data = [Height Weight Systolic Diastolic];[h,ax] = plotmatrix(data);                        % create a 4 x 4 matrix of plotsfor i = 1:4                                       % label the plots  xlabel(ax(4,i), labels{i})  ylabel(ax(i,1), labels{i})end


Visualize Function of Three Variables

For many kinds of four dimensional data, you can use color to represent the fourth dimension. This works well if you have a function of three variables.

For example, represent highway deaths in the United States as a function of longitude, latitude, and if the location is rural or urban. The x, y, and z values in the plot represent these three variables. The color represents the number of highway deaths.

claload accidents hwydata                             % load datalong = -hwydata(:,2);                              % longitude datalat = hwydata(:,3);                                % latitude datarural = 100 - hwydata(:,17);                       % percent rural datafatalities = hwydata(:,11);                        % fatalities datascatter3(long,lat,rural,40,fatalities,'filled')    % draw the scatter plotax = gca;ax.XDir = 'reverse';view(-31,14)xlabel('W. Longitude')ylabel('N. Latitude')zlabel('% Rural Population')cb = colorbar;                                     % create and label the colorbarcb.Label.String = 'Fatalities per 100M vehicle-miles';


Visualize Data in a Volume

Your data may contain a measured value for a physical object such as temperature in a pipe. In this cases, the physical dimensions can be represented as a volume with color used to represent the magnitude of the measurement. For example, use the slice function to show the value of the measured variable at cross-sections within the volume.

load fluidtemp x y z temp                       % load dataxslice = [5 9.9];                               % define the cross sections to viewyslice = 3;zslice = ([-3 0]);slice(x, y, z, temp, xslice, yslice, zslice)    % display the slicesylim([-3 3])view(-34,24)cb = colorbar;                                  % create and label the colorbarcb.Label.String = 'Temperature, C';


Plot the Function of a Complex Variable

A complex function has an input with real and imaginary parts and an output with real and imaginary parts. You can use a three dimensional plot with color to represent the complex function. In this case the x and y axes represent the real and imaginary parts of the input. The z axis represents the real part of the output and the color represents the imaginary part of the output.

r = (0:0.025:1)';                        % create a matrix of complex inputstheta = pi*(-1:0.05:1);z = r*exp(1i*theta);w = z.^3;                                % calculate the complex outputssurf(real(z),imag(z),real(w),imag(w))    % visualize the complex function using surfxlabel('Real(z)')ylabel('Imag(z)')zlabel('Real(w)')cb = colorbar;cb.Label.String = 'Imag(w)';




二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:MATLAB课程 Graphics GRAPHIC MATLAB Visual MATLAB课程 代码示例 GraphicsandVisualization VisualizingFour-DimensionalData


https://www.cda.cn/?seo-luntan
高薪就业·数据科学人才·16年教育品牌

沙发
我有我的love 在职认证  发表于 2016-3-8 14:58:54
受教,谢谢!

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-5 01:33