I am using matlab Guide. I want to take a string that I enter in an Edit text Box, and convert it into a vector of numbers so that I can plot a graph from the vector. Here is the code I wrote for converting the String into A vector of numbers:
function value = substrings (a)
j = 1;
word = a;
for i = 1:length(word)
if word(i)~= ' '
q(1,j) = str2double(word(1,i));
j = j+1;
end
end
value = q;
end
This Code eliminates spaces so if I enter '1 2 3 4 5' It wil become [1 2 3 4 5] The problem i have is i dont know how to include this in my main code so that i can input the string in the edit text box and the send it to a button to plot it.
here is the section in the Guide:
function text_Callback(hObject, eventdata, handles)
% hObject handle to text (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
word = get(hObject,'String');
for i = 1:length(word)
if word(i)~= ' '
q(1,k) = str2double(word(1,i));
k = k+1;
end
end
handles.To_Plot = q;
im going to plot handles.To_Plot with the button.