Matlab循环依赖于彼此和

时间:2017-05-13 04:53:24

标签: matlab loops vectorization

Matlab循环相互依赖,内循环的值随循环的每次迭代而变化。我如何在matlab中做到这一点?

tell application "Mail"
    activate
    set theMessage to make new outgoing message with properties {visible:true, sender:"my@email.com", subject:theSubject, content:rSpace}
    tell theMessage
        make new to recipient with properties {address:"their@email.com"}
        set acount to 1
        repeat with anAttachment in attachmentList
            make new attachment with properties {file name:anAttachment} at after the last word of the paragraph acount
            log "message_attachment = " & acount
            set acount to (acount + 1)
        end repeat

        -- send
    end tell
end tell

正如您所看到的,内部for循环的值已更改,因此矢量化无效。

1 个答案:

答案 0 :(得分:0)

试试这个:

Max=10;
A=zeros(1,Max+3);
A([1,2,3])=[3,7,2];
for i = 1:2:Max
    C = [A(i+2)-A(i)]/2;
    A(i+1:i+3) = A(i+0:i+2) + C;
end
disp(A)