如何将公式转换成字符串显示在axes上
=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
= 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
% eventdatareserved - 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)
% varargoutcell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdatareserved - 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)
% eventdatareserved - 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)
% eventdatareserved - 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)
% eventdatareserved - 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)
% eventdatareserved - 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)
% eventdatareserved - 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)
% eventdatareserved - 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)
% eventdatareserved - 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)
% eventdatareserved - 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)
% eventdatareserved - 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)
% eventdatareserved - 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)
% eventdatareserved - 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)
=zpkdata(g)
cla
axes(handles.axes1);
h1 = text('Interpreter','latex',...
'String','$$\frac{fz}{fm}{pp}$$',...
'Position',,...
'FontSize',16);
到了这步就弄不下去了.显示的不是我想要的~~~:(
用哪个参数可以将zpk 生成的式子转换成字符串.
[ 本帖最后由 eight 于 2008-2-14 09:47 编辑 ] 原帖由 cctv909 于 2008-2-13 15:18 发表 http://www.chinavib.com/forum/images/common/back.gif
=zpk(z,p,k)所生成式子中
z,p,k三个量是用户给定的,
那么它生成的式子就是不能
确定是哪个具体式子,所以如何
正确的将其显示在axes中.就是说
怎样将生成的zpk式子输出(在GUI中)
我的程序如下:
function varar ... 看不懂,请简明扼要地描述你的问题。你直接说想把什么转换成字符串吧,“zpk生成的式子”让人摸不着头脑 char()clear
clc
syms t
f=t^2*exp(-2*t)*sin(t+pi);
fl=laplace(f)
ezplot(fl);
ylabel(char(fl))
问题解释
我是想问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 编辑 ]
页:
[1]