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

If condition for syntax find

 

prudhvi_kumar_b@yahoo.com
Forum-Newbie

Forum-Newbie


Beiträge: 6
Anmeldedatum: 02.09.13
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 03.09.2013, 12:07     Titel: If condition for syntax find
  Antworten mit Zitat      
Hallo I have a matrix3*3 say A=zeros(3,3). Suppose say each row is represented as 1,2,3
I have another matrix i.e if i say B=[2,3]. My code generates 1*3 matrix for 2 and 3.
let us say that matrix a1=[1 1 0] a2=[0 0 1]. then my code replaces this values in A. now my new matrix A=[0 0 0;1 1 0;0 0 1]
every thing is fine . Now i have a problem i.e If i say B=[3,4,5] where 4,5 are not representing A(because in A the rows are represented by 1,2,3). so now i need to get new matrix as A=[0 00;0 0 0;0 01] (since for 3 the generated row matrix a2=[0 01])
please could any one help in this
Private Nachricht senden Benutzer-Profile anzeigen


Winkow
Moderator

Moderator



Beiträge: 3.842
Anmeldedatum: 04.11.11
Wohnort: Dresden
Version: R2014a 2015a
     Beitrag Verfasst am: 03.09.2013, 12:13     Titel:
  Antworten mit Zitat      
please use the code environment and post code instead of trying to discribe it in your own words. its much easyer to understand code.
you could check the size of A and then only use elements of B that is smaller then the size of A
Code:
B=B(B<=size(A,2))

_________________

richtig Fragen
Private Nachricht senden Benutzer-Profile anzeigen
 
prudhvi_kumar_b@yahoo.com
Themenstarter

Forum-Newbie

Forum-Newbie


Beiträge: 6
Anmeldedatum: 02.09.13
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 03.09.2013, 12:56     Titel:
  Antworten mit Zitat      
Confused thank you Winkow but it is not working
Here is a part of my code
Code:

azi=[2,11];     % note:this program works only if azi vector is inside the beam values
beam=-10:1:10;
[n,m]=size(beam);
A=zeros(m,100);
for i=1:length(azi);
    n1(i)=find(beam==azi(i));
    A(n1(i),:)= ones(1,100)
    end


Zuletzt bearbeitet von prudhvi_kumar_b@yahoo.com am 03.09.2013, 13:02, insgesamt einmal bearbeitet
Private Nachricht senden Benutzer-Profile anzeigen
 
Winkow
Moderator

Moderator



Beiträge: 3.842
Anmeldedatum: 04.11.11
Wohnort: Dresden
Version: R2014a 2015a
     Beitrag Verfasst am: 03.09.2013, 13:02     Titel:
  Antworten mit Zitat      
i can only repeat myself ^^ please use the code environment.
this code ist not what you discribed top i think but thats y code is better then words.

Code:
azi=[2,11]; %note:this program works only if azi vector is inside the beam values
beam=-10:1:10;
azi=azi(ismember(azi,beam));
[n,m]=size(beam);
A=zeros(m,100);
for i=1:length(azi);
n1(i)=find(beam==azi(i));
A(n1(i),:)= ones(1,100)
end

_________________

richtig Fragen
Private Nachricht senden Benutzer-Profile anzeigen
 
prudhvi_kumar_b@yahoo.com
Themenstarter

Forum-Newbie

Forum-Newbie


Beiträge: 6
Anmeldedatum: 02.09.13
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 03.09.2013, 13:10     Titel:
  Antworten mit Zitat      
Awesome its working
Thank you very much winkow Very Happy
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.