ABC of Matlab

download ABC of Matlab

of 3

Transcript of ABC of Matlab

  • 7/30/2019 ABC of Matlab

    1/3

    1.Declare a 3X3 matrixA= 1 4 6 and B= 9 8 4

    2 6 7 5 4 14 0 7 6 4 0

    ANSA= [1 4 6; 2 6 7;4 0 7]B= [ 9 8 4;5 4 1;6 4 0]

    -sin(pi/2)-tan(pi/6)-(sin(pi/6))^2 + (cos(pi/6))^2-exp(pi*sqrt(160))-7*(sqrt(13)+1)/8

    2.Create a vector v with 10 elements 1, 2, 3, .10 and compute the following.a=v e^vb= cosv/vc= (v+1)/(v-1)

    ANS.v=(1:10)a=v.*exp(v)

    b= ((cos(v)).^2)./vc= (v.^2+1)./(v.^2-1)

    3.Plot y= sin x, 0

  • 7/30/2019 ABC of Matlab

    2/3

    endguidata(hObject, handles);

    ---------

    Pushbutton_add buttons callback function: -

    a = get(handles.edit1,'String');b = get(handles.edit2,'String');% a and b are variables of Strings type, and need to be converted% to variables of Number type before they can be added togethertotal = str2num(a) + str2num(b);c = num2str(total);% need to convert the answer back into String type to display itset(handles.edit_result,'String',c);guidata(hObject, handles);

    ------------------Pushbutton_sub buttons callback function: -

    a = get(handles.edit1,'String');

    b = get(handles.edit2,'String');% a and b are variables of Strings type, and need to be converted% to variables of Number type before they can be added togethertotal = str2num(a) - str2num(b);c = num2str(total);% need to convert the answer back into String type to display itset(handles.edit_result,'String',c);guidata(hObject, handles);

    ------------

    Pushbutton_mul buttons callback function: -a = get(handles.edit1,'String');b = get(handles.edit2,'String');% a and b are variables of Strings type, and need to be converte% to variables of Number type before they can be added togethertotal = str2num(a) * str2num(b);c = num2str(total);% need to convert the answer back into String type to display itset(handles.edit_result,'String',c);guidata(hObject, handles);

    ---------------------------

    Pushbutton_div buttons callback function: -a = get(handles.edit1,'String');b = get(handles.edit2,'String');% a and b are variables of Strings type, and need to be converted% to variables of Number type before they can be added togethertotal = str2num(a) / str2num(b);c = num2str(total);% need to convert the answer back into String type to display itset(handles.edit_result,'String',c);

  • 7/30/2019 ABC of Matlab

    3/3

    guidata(hObject, handles);