Open figure in editor instead of in new window

조회 수: 117 (최근 30일)
roberto
roberto 2023년 3월 1일
편집: roberto 2023년 3월 2일
hello,
I've a creatfit function and I want to add the relative figure in editor , instead of launching a new window.
how fix it? tks
  댓글 수: 2
Jan
Jan 2023년 3월 1일
What is a "creatfit function"? What is a "relative figure"? How can a figure be opened in which editor?
Fake Name Johnson
Fake Name Johnson 2023년 3월 1일
Are you asking how to open a figure in docked mode?

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

답변 (1개)

DGM
DGM 2023년 3월 1일
편집: DGM 2023년 3월 1일
If you're asking how to programmatically dock the figure, you can set its 'windowstyle' property.
In order to create a new empty figure, you can do this.
% create an empty docked figure
figure('windowstyle','docked')
At which point, you could plot in it as usual.
You could also set the property of a figure after the fact.
% just put something in a figure
inpict = imread('cameraman.tif');
imshow(inpict)
% dock the figure
set(gcf,'windowstyle','docked') % or use a specific fig handle
  댓글 수: 3
DGM
DGM 2023년 3월 1일
편집: DGM 2023년 3월 1일
The exported script creates a new figure, so it won't use any figures created before or afterward. Unless you modify the script, you'll have to set the properties of the new figure after the script creates it.
It works for me when I either do
[fr gof] = createFit(x,y)
set(gcf,'windowstyle','docked')
or alternatively, if I modify the script:
% ...
% Plot fit with data.
figure( 'Name', 'untitled fit 1' , 'windowstyle','docked');
% ...
I think what might be happening is that there is no expected location for the docked figure. You might try docking an empty figure first so that MATLAB knows where you want the docked figure to go.
That said, I'm using R2019b, and lots of things have changed since.
roberto
roberto 2023년 3월 2일
편집: roberto 2023년 3월 2일
this is the function. I've tried both way but doesn't work. it still launch a popup window
function [fitresult, gof] = createFit1(close)
%CREATEFIT1(RESPONSE)
% Create a fit.
%
% Data for 'untitled fit 1' fit:
% Y Output: response from tbl
% Output:
% fitresult : a fit object representing the fit.
% gof : structure with goodness-of fit info.
%
% See also FIT, CFIT, SFIT.
% Auto-generated by MATLAB on 02-Mar-2023 08:28:02
%% Fit: 'untitled fit 1'.
[xData, yData] = prepareCurveData( [], response );
% Set up fittype and options.
ft = fittype( 'poly3' );
opts = fitoptions( 'Method', 'LinearLeastSquares' );
opts.Normalize = 'on';
opts.Robust = 'Bisquare';
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft, opts );
set(gcf,'windowstyle','docked') %first try (doesn't work)
% Plot fit with data.
figure( 'Name', 'untitled fit 1' , 'windowstyle','docked'); %second try (doesn't work)
h = plot( fitresult, xData, yData, 'predobs' );
legend( h, 'close', 'untitled fit 1', 'Lower bounds (untitled fit 1)', 'Upper bounds (untitled fit 1)', 'Location', 'NorthEast', 'Interpreter', 'none' );
% Label axes
ylabel( 'response', 'Interpreter', 'none' );
grid on

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

카테고리

Help CenterFile Exchange에서 Fit Postprocessing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by