声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1616|回复: 3

[GUI界面] 如何将公式转换成字符串显示在axes上

[复制链接]
发表于 2008-2-13 15:18 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
=zpk(z,p,k)所生成式子中
z,p,k三个量是用户给定的,
那么它生成的式子就是不能
确定是哪个具体式子,所以如何
正确的将其显示在axes中.就是说
怎样将生成的zpk式子输出(在GUI中)
我的程序如下:
function varargout = cdhsbdszpk(varargin)
% CDHSBDSZPK M-file for cdhsbdszpk.fig
%      CDHSBDSZPK, by itself, creates a new CDHSBDSZPK or raises the existing
%      singleton*.
%
%      H = CDHSBDSZPK returns the handle to a new CDHSBDSZPK or the handle to
%      the existing singleton*.
%
%      CDHSBDSZPK('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in CDHSBDSZPK.M with the given input arguments.
%
%      CDHSBDSZPK('Property','Value',...) creates a new CDHSBDSZPK or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before cdhsbdszpk_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to cdhsbdszpk_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Copyright 2002-2003 The MathWorks, Inc.
% Edit the above text to modify the response to help cdhsbdszpk
% Last Modified by GUIDE v2.5 10-Feb-2008 10:10:49
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @cdhsbdszpk_OpeningFcn, ...
                   'gui_OutputFcn',  @cdhsbdszpk_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT

% --- Executes just before cdhsbdszpk is made visible.
function cdhsbdszpk_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to cdhsbdszpk (see VARARGIN)
% Choose default command line output for cdhsbdszpk
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes cdhsbdszpk wait for user response (see UIRESUME)
% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = cdhsbdszpk_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;

function edit_k_Callback(hObject, eventdata, handles)
% hObject    handle to edit_k (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_k as text
%        str2double(get(hObject,'String')) returns contents of edit_k as a double

% --- Executes during object creation, after setting all properties.
function edit_k_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_k (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

function edit_z_Callback(hObject, eventdata, handles)
% hObject    handle to edit_z (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_z as text
%        str2double(get(hObject,'String')) returns contents of edit_z as a double

% --- Executes during object creation, after setting all properties.
function edit_z_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_z (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

function edit_p_Callback(hObject, eventdata, handles)
% hObject    handle to edit_p (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_p as text
%        str2double(get(hObject,'String')) returns contents of edit_p as a double

% --- Executes during object creation, after setting all properties.
function edit_p_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_p (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function edit_fz_Callback(hObject, eventdata, handles)
% hObject    handle to edit_fz (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_fz as text
%        str2double(get(hObject,'String')) returns contents of edit_fz as a double

% --- Executes during object creation, after setting all properties.
function edit_fz_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_fz (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

function edit_fm_Callback(hObject, eventdata, handles)
% hObject    handle to edit_fm (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_fm as text
%        str2double(get(hObject,'String')) returns contents of edit_fm as a double

% --- Executes during object creation, after setting all properties.
function edit_fm_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_fm (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
K=str2num(get(handles.edit_k,'String'));
Z=str2num(get(handles.edit_z,'String'));
P=str2num(get(handles.edit_p,'String'));
g=zpk(Z,P,K)
[fz,fm,pp]=zpkdata(g)
cla
axes(handles.axes1);
h1 = text('Interpreter','latex',...
'String','$$\frac{fz}{fm}{pp}$$',...
'Position',[0 0.5],...
'FontSize',16);
到了这步就弄不下去了.显示的不是我想要的~~~:(
用哪个参数可以将zpk 生成的式子转换成字符串.

[ 本帖最后由 eight 于 2008-2-14 09:47 编辑 ]
回复
分享到:

使用道具 举报

发表于 2008-2-14 09:49 | 显示全部楼层
原帖由 cctv909 于 2008-2-13 15:18 发表
=zpk(z,p,k)所生成式子中
z,p,k三个量是用户给定的,
那么它生成的式子就是不能
确定是哪个具体式子,所以如何
正确的将其显示在axes中.就是说
怎样将生成的zpk式子输出(在GUI中)
我的程序如下:
function varar ...
看不懂,请简明扼要地描述你的问题。你直接说想把什么转换成字符串吧,“zpk生成的式子”让人摸不着头脑
发表于 2008-2-14 13:58 | 显示全部楼层
char()
  1. clear
  2. clc
  3. syms t
  4. f=t^2*exp(-2*t)*sin(t+pi);
  5. fl=laplace(f)
  6. ezplot(fl);
  7. ylabel(char(fl))
复制代码

评分

1

查看全部评分

 楼主| 发表于 2008-2-17 10:35 | 显示全部楼层

问题解释

我是想问g=zpk(Z,P,K)如何把g 显示在axes上,要求就是说Z,P,K是变量(用户决定的),点了按钮直接就在axes上显示出g 的式子.
我先试试上边sogooda的方法谢谢~
sogooda的方法没搞懂啊,还是非常感谢.
要把g=ZPK(Z,P,K)这个公式显示在axes上,char()
不能把整个ZPK函数生成的式子转换成字符串,

[ 本帖最后由 cctv909 于 2008-2-17 10:59 编辑 ]
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-14 03:04 , Processed in 0.068342 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表