How to create subplots from a data set by using a function
13 ビュー (過去 30 日間)
古いコメントを表示
I am trying to make a function that will take a plotting function such as contourf or mesh, as well as nx (number of points) and dx (horizontal resolution) and will give three plots of the three arrays that are in the file. It is giving me an error saying that the plottingFunction doesn't have enough input arguments. Any ideas on what I'm doing wrong? The data file contains three double arrays which are to be plotted separately, udata, vdata and wdata
Thanks
function fig = plotVelocityComponents(plottingFunction, dx, nx)
load('dx0025_203m.mat')
x = linspace(0,nx*dx,nx);
y = linspace(0,nx*dx,nx);
%
[X, Y] = meshgrid(x,y);
Zu = udata(1:nx,1:nx)
Zv = vdata(1:nx,1:nx)
Zw = wdata(1:nx,1:nx)
%
subplot(1,3,1)
plottingFunction(X, Y, Zu)
title('u-velocity')
xlabel('x(km)')
ylabel('y(km)')
colorbar
%
subplot(1,3,2)
plottingFunction(X, Y, Zv)
title('v-velocity')
xlabel('x(km)')
ylabel('y(km)')
colorbar
%
subplot(1,3,3);
plottingFunction(X, Y, Zw);
title('w-velocity');
xlabel('x(km)');
ylabel('y(km)');
colorbar;
fig = subplot; % end
0 件のコメント
回答 (1 件)
madhan ravi
2018 年 10 月 19 日
編集済み: madhan ravi
2018 年 10 月 19 日
%%%%%script file
datas = load('dx0025_203m.mat')
dx = datas(:,1)
nx = datas(:,2) %assumption cause you didn't upload mat file
fig1 = plotVelocityComponents(plottingFunction, dx, nx) %calling of the function % changed fig as fig1 because Matlab as an inbuilt function name as fig
%%%%%%%%%function file
function fig1 = plotVelocityComponents(plottingFunction, dx, nx)
x = linspace(0,nx*dx,nx);
y = linspace(0,nx*dx,nx);
%
[X, Y] = meshgrid(x,y);
Zu = udata(1:nx,1:nx) %???--|
Zv = vdata(1:nx,1:nx) %???--|-> what are these datas?
Zw = wdata(1:nx,1:nx) %???--|
%
subplot(1,3,1)
plottingFunction(X, Y, Zu)
title('u-velocity')
xlabel('x(km)')
ylabel('y(km)')
colorbar
%
subplot(1,3,2)
plottingFunction(X, Y, Zv) % plottingFunction ? what does it mean ? no inbuilt function as such
title('v-velocity')
xlabel('x(km)')
ylabel('y(km)')
colorbar
%
fig1 = subplot;
%
end
7 件のコメント
参考
カテゴリ
Help Center および File Exchange で Discrete Data Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!