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

% Last Modified by GUIDE v2.5 26-Feb-2015 14:51:37

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

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

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = voltagealgorithm20150226gui3rd_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 selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

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


% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (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


% --- 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)


axes(handles.axes1);
cla;

for i=1:3
switch popup_sel_index

        case i
            x = [1:1:2]
            **xlRange = ('A1:B1');**
            y = xlsread('naver.xlsx','data',xlRange);
            plot(x,y)

end

end

A1:B2 を A2:B2 と A3:B3 にしたい.......

('A(i):B(i)') を試しましたが、失敗し、matlab はデータ範囲が無効であると言っています

この問題を解決するのを手伝ってください

「for 関数」を使用して A1:B2 を A2:B2 および A3:B3 にするにはどうすればよいですか?

4

2 に答える 2

0

k=1:1:4 の場合

[~,~,raw] = xlsread('data.xlsx','data1');

popup_sel_index = get(handles.popupmenu1, '値');

popup_sel_index を切り替える

    case k  
    xlRange = sprintf('E%d:CW%d',k,k);
    x1 = [0.25:0.25:24]
    xlRange
    y1 = xlsread('data.xlsx','data1',xlRange);
    plot(x1,y1)
    end

私は答えを見つけた

于 2015-02-27T06:02:45.830 に答える