matlab软件 rs rsh在哪,大佬们求教问题出在哪

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

本人是matlab萌新一个,要做个gui,画出一个函数图像,设定五个滑动条能改变图像

代码:

function varargout = solar(varargin)

% SOLAR MATLAB code for solar.fig

% SOLAR, by itself, creates a new SOLAR or raises the existing

% singleton*.

%

% H = SOLAR returns the handle to a new SOLAR or the handle to

% the existing singleton*.

%

% SOLAR('CALLBACK',hObject,eventData,handles,...) calls the local

% function named CALLBACK in SOLAR.M with the given input arguments.

%

% SOLAR('Property','Value',...) creates a new SOLAR or raises the

% existing singleton*. Starting from the left, property value pairs are

% applied to the GUI before solar_OpeningFcn gets called. An

% unrecognized property name or invalid value makes property application

% stop. All inputs are passed to solar_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 solar

% Last Modified by GUIDE v2.5 10-May-2020 20:20:44

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

gui_State = struct('gui_Name', mfilename, ...

'gui_Singleton', gui_Singleton, ...

'gui_OpeningFcn', @solar_OpeningFcn, ...

'gui_OutputFcn', @solar_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

% End initialization code - DO NOT EDIT

% --- Executes just before solar is made visible.

function solar_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 solar (see VARARGIN)

% Choose default command line output for solar

handles.output = hObject;

handles.x = 0;0.005;0.7;

x = handles.x;

m = handles.m;

il = handles.il;

i0 = handles.i0;

Rs = handles.Rs;

Rsh = handles.Rsh;

y = nt(x,m,il,i0,Rs,Rsh);

plot(handles.ivplot,x,y);

% Update handles structure

guidata(hObject, handles);

% UIWAIT makes solar wait for user response (see UIRESUME)

% uiwait(handles.figure1);

end

% --- Outputs from this function are returned to the command line.

function varargout = solar_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;

end

% --- Executes on slider movement.

function m_Callback(hObject, eventdata, handles)

% hObject handle to m (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

handles.m = get(hObject,'Value');

end

% --- Executes during object creation, after setting all properties.

function m_CreateFcn(hObject, eventdata, handles)

% hObject handle to m (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

end

% --- Executes on slider movement.

function Rs_Callback(hObject, eventdata, handles)

% hObject handle to Rs (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

handles.Rs = get(hObject,'Value');

end

% --- Executes during object creation, after setting all properties.

function Rs_CreateFcn(hObject, eventdata, handles)

% hObject handle to Rs (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

end

% --- Executes on slider movement.

function Rsh_Callback(hObject, eventdata, handles)

% hObject handle to Rsh (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

handles.Rsh = get(hObject,'Value');

end

% --- Executes during object creation, after setting all properties.

function Rsh_CreateFcn(hObject, eventdata, handles)

% hObject handle to Rsh (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

end

% --- Executes on slider movement.

function il_Callback(hObject, eventdata, handles)

% hObject handle to il (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

handles.il = get(hObject,'Value');

end

% --- Executes during object creation, after setting all properties.

function il_CreateFcn(hObject, eventdata, handles)

% hObject handle to il (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

end

% --- Executes on slider movement.

function i0_Callback(hObject, eventdata, handles)

% hObject handle to i0 (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

handles.i0 = get(hObject,'Value');

end

% --- Executes during object creation, after setting all properties.

function i0_CreateFcn(hObject, eventdata, handles)

% hObject handle to i0 (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

end

function ig=nt(V,m,il,i0,Rs,Rsh)

ig=5;

x=ig;%迭代初值

i=0;%迭代次数计算

while i<= 300%迭代次数

x0=ig-f(ig,V,m,il,i0,Rs,Rsh)/h(ig,V,m,i0,Rs,Rsh);%牛顿迭代格式

if abs(x0-ig)>0.001%收敛判断

ig=x0;

else

break

end

i=i+1;

end

end

function y=f(x,V,m,il,i0,Rs,Rsh)

y=il-i0*(exp(1.6e-19*(V+x*Rs)/(m*1.38e-23*300))-1)-(V+x*Rs)/Rsh;%原函数的表达式

end

function z=h(x,V,m,i0,Rs,Rsh)

z = -i0*1.6e-19*Rs/(m*1.38e-23*300)*exp(1.6e-19*(V+x*Rs)/(m*1.38e-23*300))-Rs/Rsh;%导函数的表达式

end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值