Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 工程数学软件 > MATLAB论坛
MATLAB论坛 一切MATLAB相关问题在此讨论。
回复
 
主题工具 显示模式
旧 2008-07-01, 22:43   #1
yangn2003
初级会员
 
注册日期: 2008-07-01
年龄: 41
帖子: 5
声望力: 0
yangn2003 正向着好的方向发展
默认 请问这个语句表示什么意思?

t=0:0.001:2*pi; %define the array t
switch flag
case 1
y=sin(w*t); %through the value of the popupmenue
case 2 %to caculate the sin, cos, tan,cot
y=cos(w*t);
case 3
y=tan(w*t);
case 4
y=cot(w*t);
end

通过和t相乘,y得出了多个值,形成了一个抛物线图,感觉t像是一个包含了多个值的数组,可是 t=0:0.001:2*pi; 又该怎么理解,0,0.001,2,pi,在这里各表示什么意思?
yangn2003 当前离线   回复时引用此帖
旧 2008-07-03, 22:30   #2
remnant
普通会员
 
注册日期: 2008-04-12
年龄: 46
帖子: 67
声望力: 19
remnant 正向着好的方向发展
默认

引用:
作者: yangn2003 查看帖子
t=0:0.001:2*pi; %define the array t
switch flag
case 1
y=sin(w*t); %through the value of the popupm...
t = 0 : 0.001 : 2*pi;

定义t的最小值为0, 最大值为2*pi,步进0.001
t = 0 , 0.001, 0.002, 0.003, 0.004, ... , 2*pi;
写成通式:
x = x_min : x_step : x_max
如果写成 x = x_min : x_max则默认x_step为1
remnant 当前离线   回复时引用此帖
旧 2008-07-06, 09:51   #3
bin629jing
初级会员
 
注册日期: 2008-07-05
年龄: 38
帖子: 1
声望力: 0
bin629jing 正向着好的方向发展
默认

这是一个求三角函数的题。
t=0:0.001:2*pi;%表示 起始值:=0,增量为:0.001,终止值:2*pi
然后用swith...case...语句得到不同的值,以 end 终止。
bin629jing 当前离线   回复时引用此帖
旧 2008-07-06, 12:41   #4
mathjiang
高级会员
 
注册日期: 2008-01-02
帖子: 247
声望力: 22
mathjiang 正向着好的方向发展
默认

楼主,在分支语句前程序中有没有交代w的值?
mathjiang 当前离线   回复时引用此帖
旧 2008-07-07, 19:06   #5
yangn2003
初级会员
 
注册日期: 2008-07-01
年龄: 41
帖子: 5
声望力: 0
yangn2003 正向着好的方向发展
默认

这个程序完整的代码是这样的:

function varargout = ex71(varargin)
% EX71 M-file for ex71.fig
% EX71, by itself, creates a new EX71 or raises the existing
% singleton*.
%
% H = EX71 returns the handle to a new EX71 or the handle to
% the existing singleton*.
%
% EX71('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in EX71.M with the given input arguments.
%
% EX71('Property','Value',...) creates a new EX71 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before ex71_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to ex71_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

% Edit the above text to modify the response to help ex71

% Last Modified by GUIDE v2.5 30-Jun-2008 21:38:38

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @ex71_OpeningFcn, ...
'gui_OutputFcn', @ex71_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 ex71 is made visible.function ex71_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 ex71 (see VARARGIN)

% Choose default command line output for ex71
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes ex71 wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = ex71_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;


% --- Executes on button press in ex71_plot.
function ex71_plot_Callback(hObject, eventdata, handles)
% hObject handle to ex71_plot (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

flag=get(handles.ex71_fun,'Value'); %get the value of the popupmenue
w=get(handles.ex71_input,'Value'); %get the value of the slider
t=0:0.001:2*pi; %define the array t
switch flag
case 1
y=sin(w*t); %through the value of the popupmenue
case 2 %to caculate the sin, cos, tan,cot
y=cos(w*t);
case 3
y=tan(w*t);
case 4
y=cot(w*t);
end

axes(handles.ex71_axes) %claim the graph drawed on the ex71_axes
plot(t,y)


% --- Executes on button press in ex71_close.
function ex71_close_Callback(hObject, eventdata, handles)
% hObject handle to ex71_close (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

close

% --- Executes on slider movement.
function ex71_input_Callback(hObject, eventdata, handles)
% hObject handle to ex71_input (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider



% --- Executes during object creation, after setting all properties.
function ex71_input_CreateFcn(hObject, eventdata, handles)
% hObject handle to ex71_input (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.

if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on button press in ex71_gridon.
function ex71_gridon_Callback(hObject, eventdata, handles)
% hObject handle to ex71_gridon (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of ex71_gridon


flag=get(hObject,'Value'); %get the value of this control
if flag==1; %if the value is 1 then use the grid
grid on;
else
grid off; %else take away the grid
end

% --- Executes on selection change in ex71_fun.
function ex71_fun_Callback(hObject, eventdata, handles)
% hObject handle to ex71_fun (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns ex71_fun contents as cell array
% contents{get(hObject,'Value')} returns selected item from ex71_fun

flag=get(hObject,'Value'); %get the value of this control
w=get(handles.ex71_input,'Value'); %get the value of the slider
if w==1
string='x)';
else
string=[num2str(w),'x]'];
end
switch flag %dymatic display the graphic
case 1
set(handles.ex71_text,'String',['The function is y=sin(',string]);
case 2
set(handles.ex71_text,'String',['The function is y=cos(',string]);
case 3
set(handles.ex71_text,'String',['The function is y=tan(',string]);
case 4
set(handles.ex71_text,'String',['The function is y=cot(',string]);
end
% --- Executes during object creation, after setting all properties.
function ex71_fun_CreateFcn(hObject, eventdata, handles)
% hObject handle to ex71_fun (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
yangn2003 当前离线   回复时引用此帖
旧 2008-07-07, 19:12   #6
yangn2003
初级会员
 
注册日期: 2008-07-01
年龄: 41
帖子: 5
声望力: 0
yangn2003 正向着好的方向发展
默认

这个pi 的值又怎么确定,是任意数吗?
yangn2003 当前离线   回复时引用此帖
旧 2008-07-08, 08:48   #7
remnant
普通会员
 
注册日期: 2008-04-12
年龄: 46
帖子: 67
声望力: 19
remnant 正向着好的方向发展
默认

引用:
作者: yangn2003 查看帖子
这个pi 的值又怎么确定,是任意数吗?
pi = 3.1415926......

maltab内置的一个常量。
remnant 当前离线   回复时引用此帖
回复


发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛禁用 HTML 代码


相似的主题
主题 主题作者 版面 回复 最后发表
[求助]请问matlab可以直接读入wmv格式文件吗 xmj34543 MATLAB论坛 1 2008-10-02 19:15
[求助]用什么模块观察和测量EVM?谢谢了 chenxin_19344834 MATLAB论坛 0 2008-05-23 15:13
Cleve's Corner: Professor SVD TechnicalArticles MATLAB技术文章 0 2008-01-06 16:32
【求助】notebook zhy3942611 MATLAB论坛 0 2007-07-09 11:34
【求助】关于非线性最小二乘拟合中的问题~ LaGeLang_Yue MATLAB论坛 0 2007-05-24 12:47


所有时间均为北京时间。现在的时间是 07:11


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.