怎樣用matlab實現do while

2021-06-22 10:57:13 字數 380 閱讀 7424

matlab 中的while迴圈只有 while statement .... end 這種迴圈結構。有時候由於問題的需要,使用do...while{}結構能夠更好的解決問題。

其實仔細分析一下,do while()的結構就是可以保證先執行一次操作,再進行判斷。

而while(條件)是先對條件進行判斷來決定是否採取相應的操作。

我採用的解決方法就是使用matlab裡面的break跳出迴圈來解決:

while 1

操作**;

if(條件)

break;%跳出迴圈

endend

這樣就能保證一進入該段**就能首先進行一次「操作**」,然後用操作**得到的結果作為if語句的判斷條件。實現了do...while()結構。

怎樣用UDP通迅

using system using system.data using system.net using system.net.sockets using system.collections using system.text using system.threading using syste...

怎樣用PL SQL表實現陣列功能

pl sql表與其他過程化語言 如c語言 的一維陣列類似。實現pl sql表需要建立乙個資料型別並另外進行變數說明。type 型別名 is table of 資料型別 index by binary integer 以下為乙個例子 declare type array type is table o...

怎樣用JS實現非同步轉同步

安裝 npm install sync 其中引用了fiber庫,用c編譯的node庫,可以實現yield 功能 詳細使用方法參見官網 url 如何使用 首先引入模組,var sync require sync 任何同步呼叫都必須位於乙個sync.block塊內,sync.block描述可以巢狀。sy...