Matlab迭代删除一行矩阵,第一次迭代除外

时间:2015-10-13 12:26:37

标签: matlab loops matrix iteration

我有一个矩阵,我用它来解决使用ode45的方程组。我在迭代循环中迭代删除一行。但是,我希望第一次迭代“继续”而不删除任何箭头,以便我可以比较使用初始矩阵删除一个数组的所有结果。

看起来像是:

while smtg
    A(pos,:)=0 % Do not compute this line the first iteration
    pop=ode45(involving A)
end

我的真实代码:

countrow=0;
A=randi([0 1], 5, 5);
distrib=sum(A,1);      
while sum(distrib)>5 
    countrow=countrow+1; 
    A(pos,:)=0; % remove one row
    options = odeset('RelTol', 1e-4);
    [t, pop]=ode45(@Diff,[0 MaxTime],[E I],options,n,m, A);
    nbtot =sum(pop(:,n+1:2*n),2);
end

我尝试使用

if countrow==1 % (the first iteration),
    continue;
end

但是它跳到第二个结束而不是计算nbtot所以我没有想法......任何帮助?

2 个答案:

答案 0 :(得分:1)

如果您不想在第一次迭代时发生cmake_minimum_required (VERSION 2.6 FATAL_ERROR) project (pcl-visualizer) find_package (Qt5 REQUIRED COMPONENTS Widgets Core) find_package (VTK REQUIRED) find_package (PCL 1.8 REQUIRED) include_directories (${PCL_INCLUDE_DIRS}) link_directories (${PCL_LIBRARY_DIRS}) add_definitions (${PCL_DEFINITIONS}) set (project_SOURCES main.cpp pclviewer.cpp) set (project_HEADERS pclviewer.h) set (project_FORMS pclviewer.ui) QT5_WRAP_CPP (project_HEADERS_MOC ${project_HEADERS}) QT5_WRAP_UI (project_FORMS_HEADERS ${project_FORMS}) ADD_DEFINITIONS (${QT_DEFINITIONS}) ADD_EXECUTABLE (pcl_visualizer ${project_SOURCES} ${project_FORMS_HEADERS} ${project_HEADERS_MOC}) TARGET_LINK_LIBRARIES (pcl_visualizer ${PCL_LIBRARIES}) qt5_use_modules (pcl_visualizer Widgets) ,请将其放在A(pos,:)=0; % remove one row语句中,如

if

MATLAB中的~=符号“不等于”。行countrow = countrow + 1; if countrow ~= 1 A(pos,:)=0; % remove one row end 现在只会在A(pos,:)=0; % remove one row 等于countrow时执行,但循环中的所有其他语句都将正常执行。

关键字continue将停止执行当前循环迭代并继续下一循环迭代。在循环中continue之后的所有语句都不会被执行。

答案 1 :(得分:1)

或者你可以选择:

10-13 17:28:42.688    7521-7521/ru.megagroup.megagrouppartner D/dalvikvm﹕ Late-enabling CheckJNI
10-13 17:28:42.739    7521-7521/ru.megagroup.megagrouppartner I/dalvikvm﹕ Could not find method android.webkit.WebView.setWebContentsDebuggingEnabled, referenced from method org.apache.cordova.engine.SystemWebViewEngine.enableRemoteDebugging
10-13 17:28:42.739    7521-7521/ru.megagroup.megagrouppartner W/dalvikvm﹕ VFY: unable to resolve static method 193: Landroid/webkit/WebView;.setWebContentsDebuggingEnabled (Z)V
10-13 17:28:42.739    7521-7521/ru.megagroup.megagrouppartner D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x0001
10-13 17:28:42.789    7521-7535/ru.megagroup.megagrouppartner D/webcoreglue﹕ netstack: Memory Cache feature is ON
10-13 17:28:42.789    7521-7521/ru.megagroup.megagrouppartner I/dalvikvm﹕ Could not find method android.webkit.CookieManager.setAcceptThirdPartyCookies, referenced from method org.apache.cordova.engine.SystemCookieManager.<init>
10-13 17:28:42.789    7521-7521/ru.megagroup.megagrouppartner W/dalvikvm﹕ VFY: unable to resolve virtual method 145: Landroid/webkit/CookieManager;.setAcceptThirdPartyCookies (Landroid/webkit/WebView;Z)V
10-13 17:28:42.789    7521-7521/ru.megagroup.megagrouppartner D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0016
10-13 17:28:42.789    7521-7521/ru.megagroup.megagrouppartner I/dalvikvm﹕ Could not find method android.webkit.CookieManager.flush, referenced from method org.apache.cordova.engine.SystemCookieManager.flush
10-13 17:28:42.789    7521-7521/ru.megagroup.megagrouppartner W/dalvikvm﹕ VFY: unable to resolve virtual method 140: Landroid/webkit/CookieManager;.flush ()V
10-13 17:28:42.789    7521-7521/ru.megagroup.megagrouppartner D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0008
10-13 17:28:42.819    7521-7521/ru.megagroup.megagrouppartner W/dalvikvm﹕ VFY: unable to find class referenced in signature (Landroid/webkit/ClientCertRequest;)
10-13 17:28:42.819    7521-7521/ru.megagroup.megagrouppartner W/dalvikvm﹕ VFY: unable to find class referenced in signature (Landroid/webkit/ClientCertRequest;)
10-13 17:28:42.819    7521-7521/ru.megagroup.megagrouppartner I/dalvikvm﹕ Could not find method android.webkit.WebViewClient.onReceivedClientCertRequest, referenced from method org.apache.cordova.engine.SystemWebViewClient.onReceivedClientCertRequest
10-13 17:28:42.819    7521-7521/ru.megagroup.megagrouppartner W/dalvikvm﹕ VFY: unable to resolve virtual method 198: Landroid/webkit/WebViewClient;.onReceivedClientCertRequest (Landroid/webkit/WebView;Landroid/webkit/ClientCertRequest;)V
10-13 17:28:42.819    7521-7521/ru.megagroup.megagrouppartner D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x001a
10-13 17:28:42.829    7521-7521/ru.megagroup.megagrouppartner W/dalvikvm﹕ VFY: unable to find class referenced in signature (Landroid/webkit/PermissionRequest;)
10-13 17:28:42.829    7521-7521/ru.megagroup.megagrouppartner I/dalvikvm﹕ Could not find method android.webkit.PermissionRequest.getResources, referenced from method org.apache.cordova.engine.SystemWebChromeClient.onPermissionRequest
10-13 17:28:42.829    7521-7521/ru.megagroup.megagrouppartner W/dalvikvm﹕ VFY: unable to resolve virtual method 156: Landroid/webkit/PermissionRequest;.getResources ()[Ljava/lang/String;
10-13 17:28:42.829    7521-7521/ru.megagroup.megagrouppartner D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x000d
10-13 17:28:42.829    7521-7521/ru.megagroup.megagrouppartner I/dalvikvm﹕ Could not find method android.webkit.WebChromeClient$FileChooserParams.createIntent, referenced from method org.apache.cordova.engine.SystemWebChromeClient.onShowFileChooser
10-13 17:28:42.829    7521-7521/ru.megagroup.megagrouppartner W/dalvikvm﹕ VFY: unable to resolve virtual method 161: Landroid/webkit/WebChromeClient$FileChooserParams;.createIntent ()Landroid/content/Intent;
10-13 17:28:42.829    7521-7521/ru.megagroup.megagrouppartner D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0000
10-13 17:28:42.829    7521-7521/ru.megagroup.megagrouppartner D/SystemWebViewEngine﹕ CordovaWebView is running on device made by: Sony
10-13 17:28:42.849    7521-7535/ru.megagroup.megagrouppartner D/JSENGINE﹕ qualcomm.jsengine.version:C.2-patch35-git:7b7ad6f
10-13 17:28:43.189    7521-7521/ru.megagroup.megagrouppartner D/libEGL﹕ loaded /vendor/lib/egl/libEGL_adreno.so
10-13 17:28:43.219    7521-7521/ru.megagroup.megagrouppartner D/libEGL﹕ loaded /vendor/lib/egl/libGLESv1_CM_adreno.so
10-13 17:28:43.229    7521-7521/ru.megagroup.megagrouppartner D/libEGL﹕ loaded /vendor/lib/egl/libGLESv2_adreno.so
10-13 17:28:43.239    7521-7521/ru.megagroup.megagrouppartner I/Adreno-EGL﹕ <qeglDrvAPI_eglInitialize:316>: EGL 1.4 QUALCOMM build:  (CL4169980)
    OpenGL ES Shader Compiler Version: 17.01.10.SPL
    Build Date: 11/04/13 Mon
    Local Branch:
    Remote Branch:
    Local Patches:
    Reconstruct Branch:
10-13 17:28:43.529    7521-7535/ru.megagroup.megagrouppartner D/HostStatisticManager﹕ netstack: DNS Host Prioritization is: ON, Version: 5.0.1
10-13 17:28:43.529    7521-7535/ru.megagroup.megagrouppartner I/﹕ netstack: LIB_MGR - Lib loaded: libdnshostprio.so
10-13 17:28:43.539    7521-7535/ru.megagroup.megagrouppartner I/﹕ netstack: STAT_HUB - Succeeded to load plugin: libdnshostprio.so
10-13 17:28:43.539    7521-7535/ru.megagroup.megagrouppartner E/﹕ netstack: LIB_MGR - Error loading lib spl_proc_plugin.so
10-13 17:28:43.539    7521-7535/ru.megagroup.megagrouppartner E/﹕ netstack: STAT_HUB - Failed to load plugin: spl_proc_plugin.so
10-13 17:28:43.539    7521-7535/ru.megagroup.megagrouppartner I/﹕ netstack: LIB_MGR - Lib loaded: pp_proc_plugin.so
10-13 17:28:43.539    7521-7535/ru.megagroup.megagrouppartner I/﹕ netstack: STAT_HUB - Succeeded to load plugin: pp_proc_plugin.so
10-13 17:28:43.539    7521-7535/ru.megagroup.megagrouppartner E/﹕ netstack:  STAT_HUB - App ru.megagroup.megagrouppartner isn't supported
10-13 17:28:43.609    7521-7521/ru.megagroup.megagrouppartner D/OpenGLRenderer﹕ Enabling debug mode 0
10-13 17:28:43.609    7521-7521/ru.megagroup.megagrouppartner I/Choreographer﹕ Skipped 43 frames!  The application may be doing too much work on its main thread.
10-13 17:28:43.960    7521-7535/ru.megagroup.megagrouppartner D/﹕ external/chromium/net/socket/tcp_fin_aggregation_factory.cc: libtcpfinaggr.so successfully loaded
10-13 17:28:43.960    7521-7535/ru.megagroup.megagrouppartner I/QCNEA﹕ |CAC| CAS is enabled
10-13 17:28:43.960    7521-7631/ru.megagroup.megagrouppartner I/QCNEA﹕ |CAC| [CNE CLIENT STATE MACHINE] transition NOT_CONNECTED_NOT_ATTEMPTED -> CONNECTING
10-13 17:28:43.960    7521-7631/ru.megagroup.megagrouppartner D/QCNEA﹕ |CAC| Connected to server socket: 76
10-13 17:28:43.960    7521-7631/ru.megagroup.megagrouppartner I/QCNEA﹕ |CAC| [CNE CLIENT STATE MACHINE] transition CONNECTING -> CONNECTED_PENDING_PERM_RESPONSE
10-13 17:28:43.960    7521-7631/ru.megagroup.megagrouppartner D/QCNEA﹕ |CAC| In monitor thread, performing select
10-13 17:28:43.960    7521-7535/ru.megagroup.megagrouppartner D/﹕ external/chromium/net/socket/tcp_fin_aggregation_factory.cc,: TCP Fin Aggregation initializing method was found in libtcpfinaggr.so
10-13 17:28:43.960    7521-7535/ru.megagroup.megagrouppartner D/TCPFinAggregation﹕ netstack: TCPFinAggregation is 1, Version 5.0.1
10-13 17:28:43.960    7521-7535/ru.megagroup.megagrouppartner D/TCPFinAggregation﹕ system property net.tcp.fin.aggregation.wait was set, value: 20
10-13 17:28:43.960    7521-7535/ru.megagroup.megagrouppartner D/TCPFinAggregation﹕ system property net.tcp.fin.aggregation.close was set, value: 300
10-13 17:28:43.960    7521-7535/ru.megagroup.megagrouppartner D/TCPFinAggregation﹕ netstack: CloseUnusedSockets is ON, (TCPFinAggregation), Version 5.0.1
10-13 17:28:44.000    7521-7631/ru.megagroup.megagrouppartner D/QCNEA﹕ |CAC| readCallback: read len:12, ret:0, errno:0
10-13 17:28:44.000    7521-7631/ru.megagroup.megagrouppartner I/QCNEA﹕ |CAC| [CNE CLIENT STATE MACHINE] transition CONNECTED_PENDING_PERM_RESPONSE -> NOT_CONNECTED_ACCESS_DENIED
10-13 17:28:44.000    7521-7631/ru.megagroup.megagrouppartner D/QCNEA﹕ |CAC| readCallback: read len:0, ret:0, errno:0
10-13 17:28:44.000    7521-7535/ru.megagroup.megagrouppartner I/QCNEA﹕ |CAC| client permission denied.
10-13 17:28:44.000    7521-7631/ru.megagroup.megagrouppartner E/QCNEA﹕ |CAC| readCallback: end of stream
10-13 17:28:44.000    7521-7631/ru.megagroup.megagrouppartner D/QCNEA﹕ |CAC| Monitor loop is terminating
10-13 17:28:44.000    7521-7535/ru.megagroup.megagrouppartner D/TCPFinAggregation﹕ Failed to get network status! received ret: -6
10-13 17:28:44.000    7521-7535/ru.megagroup.megagrouppartner D/Socket_Pool﹕ netstack: CloseUnusedSockets is ON
10-13 17:28:44.000    7521-7535/ru.megagroup.megagrouppartner D/Socket_Pool﹕ netstack: system net.statistics value: 0
10-13 17:28:44.000    7521-7535/ru.megagroup.megagrouppartner D/Socket_Pool﹕ netstack: CloseUnusedSockets is ON
10-13 17:28:44.000    7521-7535/ru.megagroup.megagrouppartner D/Socket_Pool﹕ netstack: system net.statistics value: 0
10-13 17:28:44.020    7521-7535/ru.megagroup.megagrouppartner D/﹕ external/chromium/net/http/http_getzip_factory.cc: libgetzip.so successfully loaded
10-13 17:28:44.020    7521-7535/ru.megagroup.megagrouppartner D/﹕ external/chromium/net/http/http_getzip_factory.cc,: GETzip initializing method was found in libgetzip.so
10-13 17:28:44.020    7521-7535/ru.megagroup.megagrouppartner D/﹕ netstack: Getzip is: ON, Version: 5.0.1
10-13 17:28:44.961    7521-7521/ru.megagroup.megagrouppartner D/JsMessageQueue﹕ Set native->JS mode to OnlineEventsBridgeMode
10-13 17:28:49.806    7521-7521/ru.megagroup.megagrouppartner D/TilesManager﹕ Starting TG #0, 0x5fabddd8
10-13 17:28:49.806    7521-7521/ru.megagroup.megagrouppartner D/TilesManager﹕ new EGLContext from framework: 5ebc0b08
10-13 17:28:49.806    7521-7521/ru.megagroup.megagrouppartner D/GLWebViewState﹕ Reinit shader
10-13 17:28:49.936    7521-7521/ru.megagroup.megagrouppartner D/GLWebViewState﹕ Reinit transferQueue