Why does playing an AVI file created in MATLAB not show the title, axes labels, or legend during playback?

6 ビュー (過去 30 日間)
This is my first attempt at building up a MATLAB script which utilizes the VideoWriter class. I'm attempting to plot out some achieved altitudes, and then plot the estimated altitudes on top of them.
The code I'm using is below. It outputs a .fig file (which contains no estimated altitude data, and an AVI file that contains achieved and estimated altitudes.
% Clear out the MATALB environment prior to execution
close all;
clear all;
clc;
% Enter an event title
Event_Title = 'Test';
disp(' ');
% Enter a To time
To_Time = 58560;
disp(' ');
% Enter a name of the data source to be used in the legend
Source = 'Junk';
disp(' ');
% Enter Pre-TALO times
Pre_TALO_Time = [10; 12];
% Enter some pre-altitudes
Pre_Altitude = [11.926; 240.923];
% Enter BO TALO time
BO_TALO_Time = [14.333;16.444];
% Enter some BO altitudes
BO_Altitude = [240.923;515.4021];
% Enter some post-TALO times
Post_TALO_Time = 17.54;
% enter some post-altitudes
Post_Altitude = 727.5692;
% Close all open files
fclose('all');
% Data for some trajectory
% Enter some BET TALO times
BET_TALO_Time = [10.55; 11.55; 12.55; 13.55; 14.55; 15.55; 16.55; 17.55; 18.55; 19.55; 20.55];
% Enter some BET altitudes
BET_Altitude = [111.1303; 205.7099; 285.1169; 365.4585; 446.7016; 528.8142; 611.7657; 695.5264; 780.0678; 865.3626; 951.3843];
% Plot the regular altitudes first, followed by the predicted altitudes
fid = figure('Name','Event Altitude','numbertitle','off');
axes('Position', [0.04 0.07 1.16 0.884]);
% Plot Pre-Burnout altitudes, if they exist
if size(Pre_Altitude) > 0
h = plot(Pre_TALO_Time, Pre_Altitude, '-o', 'MarkerSize', 15); % Continue here on Tuesday. Times gotta go
set(h(1), 'Color', 'r', 'MarkerFaceColor', 'r');
end
hold on;
% Plot Post-Burnout altitudes, if they exist
if size(Post_Altitude) > 0
h = plot(Post_TALO_Time, Post_Altitude, '-d', 'MarkerSize', 15);
set(h(1), 'Color', 'r', 'MarkerFaceColor', 'r');
end
% Only hold all current axes and connect the data sets if the size of
% Pre-Altitude1 and Post-Altitude 1 is > 0
if size(Pre_Altitude) & size(Post_Altitude) > 0
aa = [Pre_TALO_Time(end), Post_TALO_Time(1)];
bb = [Pre_Altitude(end), Post_Altitude(1)];
plot(aa, bb, 'r-', 'LineWidth', 1);
end
% Plot the burnout message data points, if they exist
if size(BO_Altitude) > 0
hold all;
h = plot(BO_TALO_Time, BO_Altitude, '*');
set(h(1), 'Color', 'b', 'MarkerFaceColor', 'b', 'MarkerSize', 15 );
end
% Add the title, legend, and classifications
title(Event_Title, 'Fontsize', 20, 'fontweight', 'b');
% The following is used to create a standard icon in the legend
% regardless of the combination of data sets (Pre-BO, BO, Post-BO)
plt1=plot(-100,-100,'-', 'Color', 'r');
legend(plt1,{Source}, 'Location', 'NortheastOutside');
set(legend, 'FontSize', 20);
Max_TALO_X_Values = [max(Pre_TALO_Time) max(BO_TALO_Time) max(Post_TALO_Time)];
Max_TALO_X = max(Max_TALO_X_Values);
set(gca, 'XLim', [0 10*ceil(max(Max_TALO_X)/10)]);
Max_Y_Values = [max(Pre_Altitude) max(BO_Altitude) max(Post_Altitude)];
Max_Y = max(Max_Y_Values);
set(gca, 'YLim', [0 10*ceil(max(Max_Y)/10)]);
ylim('auto');
xlabel('TALO (Sec)', 'fontsize', 20, 'fontweight', 'b');
ylabel('Altitude (Km)', 'fontsize', 20, 'fontweight', 'b');
set(gca, 'Fontsize', 16);
grid on;
box on;
% Save the figure in the current directory but don't close it
saveas(gcf,'Altitude_TALO_Linear.fig');
% Retain the current plot and add the BET plot to it. Let MATLAB adjust
% the axes limits, tick marks, and tick labels as necessary to display the
% full range of the added graph.
hold on;
% Create a video where the BET altitudes are plotted on the achieved altitudes
% Create the video writer object, specify the fps, and open the object
writerObj = VideoWriter('Video.avi');
writerObj.FrameRate = 2;
open(writerObj);
% Plot green circles indicating the BET altitudes
for i=1:size(BET_Altitude)
pause(0.1);
figure(fid);
plot(BET_TALO_Time(i),BET_Altitude(i),'og');
frame = getframe(gcf);
writeVideo(writerObj, frame);
end
% Reset the hold state
hold off;
% Close the file and the object
close(writerObj);
% Close the open figure window
close(gcf);
The .fig file can easily be modified to show the following:
The AVI file (which I can't attach) can be opened in either Windows Media Player or Quicktime. However, when I play back the video, all I can't see the title, axes labels, or legend.
Is this common for this to occur? If so, can I modify the code such that the title, axes labels, and legend can be viewed during playback?
Thank you.

採用された回答

Brad
Brad 2015 年 4 月 22 日
編集済み: Brad 2015 年 4 月 22 日
Upon further review of the question posed by the MathWorks Support Team; Why does "getframe" capture frames with different sizes when the Camera properties have been modified in MATLAB R2014a? on 24Oct2013, I modified a portion of my code to read as follows;
% Plot the regular altitudes first, followed by the predicted altitudes
fid = figure('Name','Event Altitude','numbertitle','off');
% Set a size if desired
width = 800;
height = 600;
set(fid,'Position',[15 15 width height]);
% Change the renderer to avoid bugs due to OpenGL
set(fid,'Renderer','ZBuffer');
........and the problem has been solved!

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpecifying Target for Graphics Output についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by