<kbd id="9plqc"><label id="9plqc"></label></kbd>

        <th id="9plqc"></th>
        1. <center id="9plqc"><video id="9plqc"></video></center>
          <sub id="9plqc"><form id="9plqc"><pre id="9plqc"></pre></form></sub>
          <nav id="9plqc"><form id="9plqc"><legend id="9plqc"></legend></form></nav>
          matlab中disp函數(shù)的使用 您所在的位置:網(wǎng)站首頁(yè) 屬羊54歲是哪一年的出生 matlab中disp函數(shù)的使用

          matlab中disp函數(shù)的使用

          2025-07-16 09:09| 來源: 網(wǎng)絡(luò)整理| 查看: 265

          ?

          ?

            disp函數(shù)直接將內(nèi)容輸出在Matlab命令窗口中,

          ?? 關(guān)鍵是看disp函數(shù)怎么把字符和數(shù)字在一起進(jìn)行顯示。

          matlab中disp()就是屏幕輸出函數(shù),類似于c語(yǔ)言中的printf()函數(shù)

          ?

          %%以下是一個(gè)通過給定兩點(diǎn)顯示直線方程的程序,

          %%該程序需要給出兩個(gè)點(diǎn)的坐標(biāo),結(jié)果返回為y=kx+b的格式,且求得斜率

          function [k,a1,b,type]=straight_line(A,B) % 輸入,A,B兩點(diǎn)坐標(biāo) V=B-A; a=inf; b=inf; type='undefined'; if A==B 'The two points are the same' return end if V(1)==0 && V(2)==0 disp('Enter two distinct points next time') return end if V(1)==0 type='vertical'; elseif V(2)==0 type='horizontal'; else type='oblique'; slope=atan2(V(2),V(1)); s=inv([A(1) 1;B(1) 1])*[A(2) B(2)]'; a=s(1); b=s(2); end switch type case 'vertical' disp('經(jīng)過這兩個(gè)點(diǎn)的直線方程為::'); disp(['x = ',num2str(A(1))]); case 'horizontal' disp(' 經(jīng)過這兩個(gè)點(diǎn)的直線方程為:: '); disp(['y =',num2str(A(2))]) ; case 'oblique' disp(' 經(jīng)過這兩個(gè)點(diǎn)的直線方程為:') ; disp(['y = ',num2str(a) ,' *x +',num2str(b)]); disp('斜率為:') k=num2str(a);%將符號(hào)數(shù)值化 end

          ?

          disp(X)函數(shù)只有一個(gè)輸入,當(dāng)你有多個(gè)字符串作為輸入時(shí)就會(huì)報(bào)錯(cuò)。

          例如:

          disp('Alice is ' , num2str(12) , ' years old!' );

          就會(huì)報(bào)錯(cuò)--輸入?yún)?shù)過多。

          但是將里邊的內(nèi)容用中括號(hào)一括就成了一個(gè)字符串,

          例如:

          str=['Alice is ' num2str(12) ' years old!'];

          disp(str);

          上邊這句話也就等價(jià)于:

          disp=(['Alice is ' num2str(12) ' years old!']);

          這就是加中括號(hào)的原因,而不是因?yàn)閚um2str(),

          因?yàn)閐isp(num2str(12));也是正確的,因?yàn)槔镞吘椭挥幸粋€(gè)字符串。

          ?



          【本文地址】

          公司簡(jiǎn)介

          聯(lián)系我們

          今日新聞

          推薦新聞

          專題文章
            CopyRight 2018-2019 實(shí)驗(yàn)室設(shè)備網(wǎng) 版權(quán)所有
            黄色免费网站在线看,韩国精品在线观看,韩国美女一区二区,99国产热 永康市| 盱眙县| 出国| 天津市| 罗定市| 庄浪县| 佛教| 集安市| 手游| 宁津县| 客服| 天长市| 布拖县| 黑山县| 东莞市| 含山县| 沐川县| 瓦房店市| 邓州市| 屯昌县| 巴青县| 秦皇岛市| 太湖县| 巴林右旗| 锡林郭勒盟| 邢台县| 晴隆县| 大悟县| 眉山市| 巴彦淖尔市| 延川县| 长海县| 禄劝| 嘉峪关市| 大邑县| 黔西县| 乐陵市| 抚顺县| 九江市| 乾安县| 农安县| http://444 http://444 http://444 http://444 http://444 http://444