matlab 对话框保持,如何在matlab中创建输入对话框?(How to create Input dialog box in matlab?)...
如何在matlab中創(chuàng)建輸入對話框?(How to create Input dialog box in matlab?)
我想在matlab中創(chuàng)建輸入對話框。 我在MATLAB中執(zhí)行簡單的加法運算。 需要由用戶給出兩個變量name,a和b,然后執(zhí)行加法c = a + b; 并將其顯示在輸出中。 a和b都應該只是正整數(shù)。 我試過以下:
a = inputdlg({'Enter positive integer (a)'});
b = inputdlg({'Enter positive integer (b)'});
c=a+b;
但是它給出了以下錯誤:
未定義的函數(shù)或方法'plus'表示'cell'類型的輸入?yún)?shù)。
請建議我如何以描述的方式編寫上述程序。
I want to create input dialog box in matlab. I am performing simple addition operation in MATLAB. Two variables name, a and b are needed to be given by user and then performing addition c=a+b; and display it in output. Both a and b should be positive integer only. I tried following:
a = inputdlg({'Enter positive integer (a)'});
b = inputdlg({'Enter positive integer (b)'});
c=a+b;
But it is giving following error:
Undefined function or method 'plus' for input arguments of type 'cell'.
Please suggest how can i code the above program in described way.
原文:https://stackoverflow.com/questions/35240495
2020-05-10 12:05
滿意答案
那是因為inputdlg的輸出是一個包含字符串的單元格數(shù)組; 這里有1個單元陣列。
因此,您需要訪問單元陣列的內(nèi)容以執(zhí)行操作; 例如使用{花括號}: {a}和 。
在您的情況下,由于您要求使用數(shù)字,您需要將輸出(字符串)轉(zhuǎn)換為Matlab可以使用的實際數(shù)字,例如str2double ,它在單元格數(shù)組上運行
c = str2double(a) + str2double(b)
That's because the output of inputdlg is a cell array containing a string; here a 1-cell array.
Hence you need to access the content of the cell array to perform the operation; for example using {curly brackets} : {a} and .
In your case, since you are asking the use for a number, you need to convert the output, which is a string, to an actual number Matlab can use using for instance str2double, which operates on cell arrays
c = str2double(a) + str2double(b)
2016-02-06
相關(guān)問答
使用所有必需的輸入字段創(chuàng)建Windows窗體,您可以選擇使用MaskedTextBox控件來驗證或使用ErrorProvider控件創(chuàng)建正常的TextBox控件(請參閱下面的鏈接)。 作為模態(tài)對話框啟動窗體。 http://msdn.microsoft.com/en-us/library/system.windows.forms.maskedtextbox.aspx http://msdn.microsoft.com/en-us/library/system.windows.forms.error...
使用Activtiy上下文 替換這個 final EditText input = new EditText(this);
通過 final EditText input = new EditText(MainActivity.this);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PAR...
你想要一個我認為的InputBox http://msdn.microsoft.com/en-us/library/6z0ak68w(v=vs.90).aspx dim myValue as String = InputBox("Enter Value", "Enter Value", "Please Enter Value")
You want an InputBox I think http://msdn.microsoft.com/en-us/library/6z0ak68w(v=vs.9...
你可以試試這個: 小提琴 HTML:
Click Me!
jQuery的: $(document).ready(function() {
$("button").click(function() {
$("#dialog").dialog({
resizable: false,
...
如果要以編程方式觸發(fā)對話框的visible可以使用visible屬性執(zhí)行此操作: 您在xhtml中的對話框:
...
你的支持bean: @ManagedBean
@RequestScoped
public class Ba...
message = sprintf('Your answer is %d', var)
msgbox(message)
message = sprintf('Your answer is %d', var)
msgbox(message)
Cocos2d沒有提供這樣做的方法。 您必須構(gòu)建自己的解決方案或使用UIKit添加UITextField。 Cocos2d does not provide with a way of doing that. You would have to either build you own solution or use UIKit to add a UITextField for example.
以下是keyup事件的示例。 但是你可以綁定任何可用的事件: jQuery("body").on("keyup", "#t2e_w", function() {
var input_user = jQuery('#t2e_w').val();
console.log(input_user);
//reg expression here ...
});
小提琴: http : //jsfiddle.net/j6R22/22/ Here is a example with the key...
您可以在按鈕事件上使用event delegation $(document).on('click','。remove',function(){將綁定綁定事件時不存在的.remove元素上的事件。這稱為事件委托 $(document).on('click','.remove', function() {
// your code here
})
You can use event delegation on button events $(document).on('click','.r...
那是因為inputdlg的輸出是一個包含字符串的單元格數(shù)組; 這里有1個單元陣列。 因此,您需要訪問單元陣列的內(nèi)容以執(zhí)行操作; 例如使用{花括號}: {a}和 。 在您的情況下,由于您要求使用數(shù)字,您需要將輸出(字符串)轉(zhuǎn)換為Matlab可以使用的實際數(shù)字,例如str2double ,它在單元格數(shù)組上運行 c = str2double(a) + str2double(b)
That's because the output of inputdlg is a cell array conta...
相關(guān)文章
中文名: MATLAB及應用 作者: 胡鶴飛 圖書分類: 軟件 資源格式: PDF
...
所有輸入框都是在iframe下面的。瀏覽器自帶的 input自動提示框 在input框下方 40px左
...
http://gumstix.org/create-a-bootable-microsd-card.h
...
ClientProtocol負責完成HDFS Client與NameNode之間的交互。本文主要分析一
...
http://wiki.apache.org/solr/MergingSolrIndexes http
...
中文名: MATLAB智能算法30個案例分析 作者: 史峰 王輝 郁磊 胡斐
...
中文名: 模式識別與智能計算:MATLAB技術(shù)實現(xiàn)(第2版) 作者: 楊淑瑩 圖書分類:
...
在看struts2自帶的crud的例子中,struts.xml中的crud!input、crud!de
...
中文名: 數(shù)字圖像處理與機器視覺:Visual C++與Matlab實現(xiàn) 作者: 張錚 圖
...
new AlertDialog.Builder(Login.this) .setIcon(getR
...
最新問答
如果啟用了復制處理程序,請確保將其置于其中一個安全角色之后。 我見過人們做的另一件事是在不同的端口上運行admin。 最好在需要auth的頁面上使用SSL,這樣你就不會發(fā)送明確的密碼,因此管理和復制將發(fā)生在8443上,而常規(guī)查詢將在8080上發(fā)生。 如果您要簽署自己的證書,請查看此有用的SO頁面: 如何在特定連接上使用不同的證書? I didn't know that /admin was the context for SOLR admin because /admin does not re
第一:在您的樣本中,您有: 但是你在詢問 //td[@class=‘CarMiniProfile-TableHeader’] (注意TableHeader中的大寫'T')。 xpath區(qū)分大小寫。 第二:通過查詢// td [@ class ='CarMiniProfile-TableHeader'] / td,你暗示你在外部td中有一個'td'元素,而它們是兄弟姐妹。 有很多方法可以在這里獲得制作和模型
這是你的答案: http://jsfiddle.net/gPsdk/40/ .preloader-container { position: absolute; top: 0px; right: 0px; bottom: 0px; left: 0px; background: #FFFFFF; z-index: 5; opacity: 1; -webkit-transition: all 500ms ease-out;
問題是,在啟用Outlook庫引用的情況下, olMailItem是一個保留常量,我認為當您將Dim olMailItem as Outlook.MailItem ,這不是問題,但是嘗試設置變量會導致問題。 以下是完整的解釋: 您已將olMailItem聲明為對象變量。 在賦值語句的右側(cè),在將其值設置為對象的實例之前,您將引用此Object 。 這基本上是一個遞歸錯誤,因為你有對象試圖自己分配自己。 還有另一個潛在的錯誤,如果之前已經(jīng)分配了olMailItem ,這個語句會引發(fā)另一個錯誤(可能是
我建議使用wireshark http://www.wireshark.org/通過記錄(“捕獲”)設備可以看到的網(wǎng)絡流量副本來“監(jiān)聽”網(wǎng)絡上發(fā)生的對話。 當您開始捕獲時,數(shù)據(jù)量似乎過大,但如果您能夠發(fā)現(xiàn)任何看起來像您的SOAP消息的片段(應該很容易發(fā)現(xiàn)),那么您可以通過右鍵單擊并選擇來快速過濾到該對話'關(guān)注TCP Stream'。 然后,您可以在彈出窗口中查看您編寫的SOAP服務與Silverlight客戶端之間的整個對話。 如果一切正常,請關(guān)閉彈出窗口。 作為一個額外的好處,wireshar
Android默認情況下不提供TextView的合理結(jié)果。 您可以使用以下庫并實現(xiàn)適當?shù)腶ligntment。 https://github.com/navabi/JustifiedTextView Android Does not provide Justified aligntment of TextView By default. You can use following library and achieve proper aligntment. https://github.com/
你的代碼適合我: class apples { public static void main(String args[]) { System.out.println("Hello World!"); } } 我將它下載到c:\ temp \ apples.java。 以下是我編譯和運行的方式: C:\temp>javac -cp . apples.java C:\temp>dir apples Volume in drive C is HP_PAV
12個十六進制數(shù)字(帶前導0x)表示48位。 那是256 TB的虛擬地址空間。 在AMD64上閱讀wiki(我假設你在上面,對嗎?)架構(gòu)http://en.wikipedia.org/wiki/X86-64 12 hex digits (with leading 0x) mean 48 bits. That is 256 TB of virtual address space. Read wiki on AMD64 (I assume that you are on it, right?) ar
這將取決于你想要的。 對象有兩種屬性:類屬性和實例屬性。 類屬性 類屬性對于類的每個實例都是相同的對象。 class MyClass: class_attribute = [] 這里已經(jīng)為類定義了MyClass.class_attribute ,您可以使用它。 如果您創(chuàng)建MyClass實例,則每個實例都可以訪問相同的class_attribute 。 實例屬性 instance屬性僅在創(chuàng)建實例時可用,并且對于類的每個實例都是唯一的。 您只能在實例上使用它們。 在方法__init__中定
總結(jié)
以上是生活随笔為你收集整理的matlab 对话框保持,如何在matlab中创建输入对话框?(How to create Input dialog box in matlab?)...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: (转)[教你开启冻酸奶的app2sd]
- 下一篇: 旋转编码器c语言程序,【E课堂】旋转编码