Please view the files below, I need help plotting them. Thanks in advance.

댓글 수: 5

Dyuman Joshi
Dyuman Joshi 2023년 10월 2일
Use load to load the variables from the .mat files into workspace and use the appropriate function to plot the data.
Abdulla AlAnsari
Abdulla AlAnsari 2023년 10월 2일
Can you help me with the ‘appropriate function’. I can load all the Files in. Just issues with plotting.
Dyuman Joshi
Dyuman Joshi 2023년 10월 2일
"Can you help me with the ‘appropriate function’."
That depends. Which type of plot do you want to do?
Abdulla AlAnsari
Abdulla AlAnsari 2023년 10월 2일
I need my plots to be similar to the below:
Dyuman Joshi
Dyuman Joshi 2023년 10월 3일
Well @Abdulla AlAnsari, @Star Strider has been kind enough to provide you with a full working solution.
Check the answer below.

댓글을 달려면 로그인하십시오.

 채택된 답변

Star Strider
Star Strider 2023년 10월 2일
편집: Star Strider 2023년 10월 2일

0 개 추천

If you want to plot the ‘wl’ field in each one, this works —
Files = dir('*.mat');
figure
tiledlayout(3,3)
for k = 1:numel(Files)
Name = Files(k).name;
LD = load(Files(k).name);
wl = LD.wl;
nexttile
plot(wl(:,1), wl(:,2),'-r')
hold on
plot(wl(:,1), wl(:,3),'-b')
hold off
grid
grid('minor')
title(Name)
end
Make appropriate changes to get the desired result.
EDIT — (2 Oct 2023 at 19:02)
Added this —
Apparently this is a ‘guess what I want to plot’ problem.
Select the ‘wl’ field instead, since that appears to be the most promising.
Choose the two files you want to plot, using the ‘FileSelection’ vector (any two will work, and in any order, providing the numbers are between 1 and 9).
figure
tiledlayout(2,1)
FileSelection = [7 6];
for k = 1:2
Name1 = extractBefore(Files(FileSelection(k)).name,'.');
LD1 = load(Files(FileSelection(k)).name);
wl1 = LD1.wl;
% Name2 = extractBefore(Files(k+1).name,'.');
% LD2 = load(Files(k+1).name);
% wl2 = LD2.wl;
nexttile
plot(wl1(:,1), wl1(:,2), '-r', 'DisplayName','Input Signal')
hold on
plot(wl1(:,1), wl1(:,3), '-b', 'DisplayName','Response')
hold off
grid
grid('minor')
xlabel('Time (s)')
ylabel('Input Signal (rad/s)')
legend('Location','best')
title(Name1)
end
.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

제품

릴리스

R2022b

태그

질문:

2023년 10월 2일

댓글:

2023년 10월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by