Plotting simplenarx_dataset
조회 수: 10 (최근 30일)
이전 댓글 표시
I tried to plot the simplenarx_dataset but it is coming up blank (i get a graph with x and y axis but no data in it). Can anyone help me?
load simplenarx_dataset;
data = simplenarx_dataset;
figure; plot(data{1});
hold on;
plot(data{2});
xlabel('Time');
ylabel('Value');
legend('Input', 'Output');
댓글 수: 3
채택된 답변
Voss
2023년 8월 24일
simplenarx_dataset.mat is a mat-file; simplenarx_dataset.m is a function m-file.
When you load simplenarx_dataset, you load the variables contained in the mat-file into the workspace. These variables are simplenarxInputs and simplenarxTargets.
load simplenarx_dataset
whos
When you call the function simplenarx_dataset, you get up to two outputs, which are the same two variables contained in the mat-file.
[inputs,targets] = simplenarx_dataset();
whos
isequal(inputs,simplenarxInputs) % the first output from simplenarx_dataset() is simplenarxInputs from the mat-file
isequal(targets,simplenarxTargets) % the second output from simplenarx_dataset() is simplenarxTargets from the mat-file
You can inspect the contents of the m-file to see that it is in fact loading the mat-file and returning the requested variables (scroll down to the end):
type simplenarx_dataset.m
That's all to say that, in your code, the load is unnecessary because you don't do anything with the loaded variables simplenarxInputs and simplenarxTargets. Instead you are calling simplenarx_dataset.m on the next line, with one output, which makes your variable data have the value of simplenarxInputs from the mat-file, which is the first output of the function simplenarx_dataset.
Now for the question you asked: why do plot(data{1}) and plot(data{2}) not produce any visible result?
That's because data{1} and data{2} are each scalars, i.e., the cells in positions 1 and 2 (in fact in all positions) of data each contain only a single value, so you are plotting only single points. You cannot see a single point unless you use a data marker.
figure;
data = simplenarx_dataset();
plot(data{1},'o'); % marker 'o'
hold on;
plot(data{2},'x'); % marker 'x'
xlabel('Time');
ylabel('Value');
legend('Input', 'Output');
Maybe you want to get both outputs from simplenarx_dataset(), and plot them against each other.
figure
[data,targets] = simplenarx_dataset();
data = [data{:}];
targets = [targets{:}];
plot(data,targets,'.')
댓글 수: 4
추가 답변 (1개)
Dyuman Joshi
2023년 8월 24일
simplenarx_dataset is a 1x100 cell array, with each cell element containing a numerica scalar.
load simplenarx_dataset;
data = simplenarx_dataset
When plotting a numeric scalar via plot, you will need to specify a marker to show the point on the figure -
figure;
plot(data{1},'r*');
hold on;
plot(data{2},'bo');
xlabel('Time');
ylabel('Value');
legend('Input', 'Output');
You can also use scatter to show scalar points on figure, which does not require markers input for that.
참고 항목
카테고리
Help Center 및 File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


