WICHTIG: Der Betrieb von goMatlab.de wird privat finanziert fortgesetzt. - Mehr Infos...

Mein MATLAB Forum - goMatlab.de

Mein MATLAB Forum

 
Gast > Registrieren       Autologin?   

Partner:




Forum
      Option
[Erweitert]
  • Diese Seite per Mail weiterempfehlen
     


Gehe zu:  
Neues Thema eröffnen Neue Antwort erstellen

vector zerlegen und als matrix speichern

 

mscoiat

Gast


Beiträge: ---
Anmeldedatum: ---
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 06.12.2011, 13:54     Titel: vector zerlegen und als matrix speichern
  Antworten mit Zitat      
I got a vector and I would like to transform certain parts of this vector into a new matrix without using loops.
e.g. vector v=[1;2;3;4;5;6;7;8;9] and I would like to get the 4th and the 8th entry plus the two entrys before.
from v=[1;2;3;4;5;6;7;8;9] to result=[2,3,4;6,7,8]

I tried to do it like this but it gets me only the first row of the result matrix

i=[4;8]
result=v(i:i-2)

Any help is appreciated!
Thanks


Jan S
Moderator

Moderator


Beiträge: 11.057
Anmeldedatum: 08.07.10
Wohnort: Heidelberg
Version: 2009a, 2016b
     Beitrag Verfasst am: 06.12.2011, 18:47     Titel: Re: vector zerlegen und als matrix speichern
  Antworten mit Zitat      
Dear mscoiat,

This is a German forum.

You cannot use the colon-operator ":" for vectors. Therefore "i:i-2" does not work. Another problem: "4:4-2" would create the empty matrix, because the colon operator increses the argument in steps of one. Try this: "4-2:4".

Kind regards, Jan
Private Nachricht senden Benutzer-Profile anzeigen
 
Neues Thema eröffnen Neue Antwort erstellen



Einstellungen und Berechtigungen
Beiträge der letzten Zeit anzeigen:

Du kannst Beiträge in dieses Forum schreiben.
Du kannst auf Beiträge in diesem Forum antworten.
Du kannst deine Beiträge in diesem Forum nicht bearbeiten.
Du kannst deine Beiträge in diesem Forum nicht löschen.
Du kannst an Umfragen in diesem Forum nicht mitmachen.
Du kannst Dateien in diesem Forum posten
Du kannst Dateien in diesem Forum herunterladen
.





 Impressum  | Nutzungsbedingungen  | Datenschutz | FAQ | goMatlab RSS Button RSS

Hosted by:


Copyright © 2007 - 2025 goMatlab.de | Dies ist keine offizielle Website der Firma The Mathworks

MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.