I am struggling to plot my data on Two y-Axis. Can you someone please help me out.
U wind velocity component for each location and altitude is store in the variable Uw (lon,lat,P) and the V wind velocity component is stored in the variable Vw(lon,lat,P_range).
My desire is to plot the Uw and Vw on different y-axis and the P_rang on the x-axis for any given location.
I have attached the test.mat files containing the variables.
Thank you for your help.

 Akzeptierte Antwort

Simon Chan
Simon Chan am 18 Aug. 2021

0 Stimmen

use function yyaxis yyaxis

3 Kommentare

Thank you for the feedback.
I used the code shown below but it is not giving the desired result.
yyaxis left
plot(P_range,Uw(74,53,1))
yyaxis right
plot(P_range,Vw(74,53,1))
Now I understand and hope the following is what you need.
In this case, you need to select a particular location (lon,lat) and plot them still using function yyaxis.
The example below shows the wind velocity components at location (10,20) and use the values of P_range as x-axis (First figure). If the actual values of P_range is not important and you would like to have number of data as the x-axis, you may replace the variable P_range by 1:24 (Second figure).
clear; clc;
load('test.mat')
lon = 10;
lat = 20;
Udata = Uw(lon,lat,:);
Vdata = Vw(lon,lat,:);
yyaxis left
plot(P_range,Udata(:))
ylabel('Uw')
grid on
yyaxis right
plot(P_range,Vdata(:))
ylabel('Vw')
xlabel('P_range')
legend('Uw','Vw')
Telema Harry
Telema Harry am 19 Aug. 2021
Thank you @Simon Chan

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

darova
darova am 18 Aug. 2021

0 Stimmen

You have 3D data. How do you want it to plot in 2d?
s = load('test.mat')
s = struct with fields:
P_range: [24×1 single] Uw: [86×86×24 double] Vw: [86×86×24 double]

1 Kommentar

Telema Harry
Telema Harry am 18 Aug. 2021
Thank you for the feedback @darova
My main objective is to visualize the variable of Uw and Vw at different P_range values.
For example, at Uw(10,20,:) I want to see the different values Uw for all P_range(1:24). and same for Vw.
I understand that I can only do it point by point using this approach.
At the end, I want to acheive the graph shown below.

Melden Sie sich an, um zu kommentieren.

Produkte

Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by