May I know what is this error? in gui to stress-strain model in for-end

1 view (last 30 days)
function varargout = dmmGUI210530(varargin)
% DMMGUI210530 MATLAB code for dmmGUI210530.fig
% DMMGUI210530, by itself, creates a new DMMGUI210530 or raises the existing
% singleton*.
%
% H = DMMGUI210530 returns the handle to a new DMMGUI210530 or the handle to
% the existing singleton*.
%
% DMMGUI210530('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in DMMGUI210530.M with the given input arguments.
%
% DMMGUI210530('Property','Value',...) creates a new DMMGUI210530 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before dmmGUI210530_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to dmmGUI210530_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 dmmGUI210530
% Last Modified by GUIDE v2.5 19-Jan-2022 17:36:10
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @dmmGUI210530_OpeningFcn, ...
'gui_OutputFcn', @dmmGUI210530_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 dmmGUI210530 is made visible.
function dmmGUI210530_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 dmmGUI210530 (see VARARGIN)
% Choose default command line output for dmmGUI210530
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes dmmGUI210530 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = dmmGUI210530_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 velocity_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function velocity_CreateFcn(hObject, eventdata, handles)
% Hint: edit 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
function Distance_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function Distance_CreateFcn(hObject, eventdata, handles)
% Hint: edit 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 Button.
function StartButton_Callback(hObject, eventdata, handles)
% set(handles.Filename,'String',string(datetime('now','Format','yyyyMMdd_0')));
newobjs = instrfind; %usb로 값 읽어들이기 시작
if isempty(newobjs) == 0
fclose(newobjs);
delete(newobjs);
clear newobjs
end
%
% DutAddr = 'GPIB0::22::INSTR'; %String for GPIB의 adress를 DutAddr에 저장
%
% %connects with instrument and configures
% myDmm = visa('agilent',DutAddr); %myDmm에 DutAddr 입력하여 디지털 멀티미터 동작할 수 있게 설정
% set(myDmm,'EOSMode','read&write'); % read&write 동작 하도록 멀티미터 setting
% set(myDmm,'EOSCharCode','LF') ;
% fopen(myDmm);
%
%
% %Configure for DCV 1V range, 100uV resolution
% fprintf(myDmm,'CONF:VOLT:DC 10, 0.0001'); %digital multimeter 화면에 나오는 부분 설정
% % DC voltage, 최대 단위 10, 최소 단위
% % 0.0001V까지 나타나도록 설정
v = str2double(get(handles.velocity, 'String')); %GUI에서 velocity값 읽어와서 v에 저장
% s = str2double(get(handles.sampling,'String')); % s=500; GUI에서 sampling값 읽어와서 s에 저장
D = str2double(get(handles.Diameter, 'String')); %GUI에서 diameter값 읽어와서 D에 저장
name = get(handles.Filename,'String'); % name = '원하는 이름 설정', GUI에서 설정한 파일 이름 읽어와서 name에 저장
file = '.xls'; %엑셀파일로 저장하기 위한 부분
loadcell = serial('COM3', 'BaudRate', 9600);
fopen(loadcell);
pause(2);
direction=get(handles.direction,'Value');
switch direction
case 1
direction="UP\n";
case 2
direction="DOWN\n";
case 3
direction="RE";
end
loadcell_speed=num2str(100/str2double(get(handles.velocity,'String')));
%loadcell_speed=get(handles.velocity,'String');
fprintf(loadcell,direction);
fprintf(loadcell, loadcell_speed);
fprintf(loadcell,'\n');
%time=num2str(4./str2double(get(handles.velocity,'String'))*str2double(get(handles.distance,'String'));
%time = num2str(100./4*(str2double(get(handles.velocity, 'string'))).\str2double(get(handles.distance, 'string'))*1000)
%거리 / 속력
time = num2str((100/str2double(get(handles.velocity,'String'))).\str2double(get(handles.distance, 'string'))*1000*(10/4));
time='1000';
fprintf(loadcell, time);
fprintf('%s ms\n',time);
tStart = tic; %timer 시작 함수
disp("타이머시작")
t=0;
delta_L=0;
for
Invalid expression. Check for missing or extra characters.
vec(i) = str2double(query(myDmm, 'READ?')); %vec(i)번째에 읽어들인 값 저장
disp(vec(i)./10);
tEnd(i) = toc(t_sampling); % 측정된 시간 tEnd에 저장, 10000/2로 실제 초와 같게 설정
delta_L = delta_L+tEnd(i)*v;
L(i) = delta_L; %모터가 움직이는 시간에 따라 모터가 움직인 거리 설정 (속력*시간 = 거리)
end
fprintf('Approximately %f sec.\n', toc(tStart)); % 최종적으로 걸린 시간 출력
fprintf('%s\n',fscanf(loadcell,'%[^\n]%*s'));
disp()
fclose(loadcell);
A = pi*(D/2)^2*10^(-6); %읽어들인 D(diameter)값으로 단면적A 계산
data_volt = [vec']; %vec배열을 data_volt 에 저장
data_time = [tEnd']; %tEnd배열을 data_time에 저장
delta_Length = [L']; %L배열을 data_time에 저장
data_cell = horzcat(data_time, delta_Length, data_volt*4.6083); %data_time, data_length, data_volt를 세로로 합침
%1열+1열+1열=3열
%data_volt에0.00456을곱하여voltage->Newton:calibration
%data_volt*0.00456/A
xlswrite(strcat(name, file), data_cell); % make excel sheet
%plot
%figure,
%plot(L,vec*4.6083) %1V=4.56g=0.00456N (1kg=9.8N), L = delta length ***나중에 vec*0.00456/A로 바꿔주세영
title('F-Length Graph')
xlabel('Length(mm)')
ylabel('F(N)') %**F/A(Pa)
grid on
% for i=5:10
% M=movmean(vec*0.46083,i*10);
% figure,
% plot(L,M) % (1kg=9.8N), L = delta length ***나중에 vec*0.00456/A로 바꿔주세영
% title('F-Length Graph')
% xlabel('Length(mm)')
% ylabel('F(N)') %**F/A(Pa)
% grid on
% end
M=movmean(vec*4.6083,100);
%figure,
%plot(L,M) %1V=4.56g=0.00456N (1kg=9.8N), L = delta length ***나중에 vec*0.00456/A로 바꿔주세영
title('F-Length Graph')
xlabel('Length(mm)')
ylabel('F(N)') %**F/A(Pa)
grid on
function Filename_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function Filename_CreateFcn(hObject, eventdata, handles)
% Hint: edit 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
function sampling_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function sampling_CreateFcn(hObject, eventdata, handles)
% Hint: edit 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
function fiberLength_Callback(hObject, eventdata, handles)
get(handles.fiberLength, 'String');
% --- Executes during object creation, after setting all properties.
function fiberLength_CreateFcn(hObject, eventdata, handles)
% Hint: edit 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
function fiberLength_eidtText_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function fiberLength_eidtText_CreateFcn(hObject, eventdata, handles)
% Hint: edit 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
function Diameter_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function Diameter_CreateFcn(hObject, eventdata, handles)
% Hint: edit 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 during object creation, after setting all properties.
function figure1_CreateFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% global loadcell
% --- Executes during object deletion, before destroying properties.
function figure1_DeleteFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
delete(instrfindall);
function speed_Callback(hObject, eventdata, handles)
% hObject handle to speed (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 speed as text
% str2double(get(hObject,'String')) returns contents of speed as a double
% --- Executes during object creation, after setting all properties.
function speed_CreateFcn(hObject, eventdata, handles)
% hObject handle to speed (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function distance_Callback(hObject, eventdata, handles)
% hObject handle to distance (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 distance as text
% str2double(get(hObject,'String')) returns contents of distance as a double
% --- Executes during object creation, after setting all properties.
function distance_CreateFcn(hObject, eventdata, handles)
% hObject handle to distance (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in direction.
function direction_Callback(hObject, eventdata, handles)
% hObject handle to direction (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 direction contents as cell array
% contents{get(hObject,'Value')} returns selected item from direction
% --- Executes during object creation, after setting all properties.
function direction_CreateFcn(hObject, eventdata, handles)
% hObject handle to direction (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
my error is like this
error: file: dmmGUI210530.m line: 176 row: 4

Answers (1)

Walter Roberson
Walter Roberson on 6 Jul 2022
You currently have
delta_L=0;
for
vec(i) = str2double(query(myDmm, 'READ?')); %vec(i)번째에 읽어들인 값 저장
However, you need to complete that for statement. It appears that it should be
for i = 1 : SOMETHING
but I cannot tell what the SOMETHING limit should be.
Note:
time = num2str((100/str2double(get(handles.velocity,'String'))).\str2double(get(handles.distance, 'string'))*1000*(10/4));
The .\ operator is very obscure, and you should probably never use it. For scalar A and B, A.\B is the same as B./A which is a lot clearer to write. Do you want velocity divided by distance, or do you want distance divided by velocity ?

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!