Sei sulla pagina 1di 6

5/4/2015

*Loadandeditafile.bdf(Patran)[Solved]

Forums Tutorials Magazine FAQs Blogs Projects Cat Newsletter Studies Employment Club Contacts

Welcome
EDI

ALM

Java

.NET

Dev.Web

EDI

Programming

DBMS

Office

BusinessSolutions

Applications

Phones

Systems

4D Delphi Eclipse LabVIEW NetBeans MATLAB Scilab VisualStudio WinDev VisualBasic6 Lazarus QtCreator
HomeMATLAB

ForumsMATLAB

FAQsMATLAB

MATLABTutorials

Help
Stock

SocialNetwork
Identifiant

Boardindex

Blogs Diary
Motdepasse
Rules

DevelopmentEnvironments

RememberMe?

MATLABBooks

MATLABSources

Tosignup
Advancedsearch
Login

MATLAB

*Loadandeditafile.bdf(Patran)
[Solved]

Ifthisisyourfirstvisit,besuretocheckouttheFAQbyclickingthelinkabove.Youmayneedyouregisterbeforeyoucanpost:clickthe
registerlinkaboveforthat.Tostartviewingmessages,selecttheforumthatyouwanttovisitfromtheselectionbelow.

+ReplytoThread
Thread:*Loadandeditafile.bdf(Patran)[Solved]

Results1to10of10

ThreadTools

#1

07/10/2011,4:47p.m.

mfontan

*Loadandeditafile.bdf(Patran)

NewClub

Joined:
2007
Posts:
Points:

November
98
29

Goodmorning,Iwanttoloadfromamatlab*.bdffilethatisgeneratedfromcodetoEF
Patran(PreProusableforNastran).Iputthe*.bdffilePJtogiveanideaofwhatitlookslike.
Iwouldliketoprovideloadautomaticallyandchangeittoaspecificlocationandsaveitfor
reuse.sotherewasseveralthings:1/downloadthefileinmatlab2/targetportiontobe
changed3/savethe.modifiedfiletoreturnittotheEFPatransoftwareIblockabout2.I
policyholderinfoifyouhaveanswerstomyproblem,fornow,here'sthecode:forexample,I
trytochangethevalues
ofbush_hautwhicharethenumberslocatedinthelowerline.

http://www.developpez.net/forums/d1139654/environnementsdeveloppement/matlab/chargermodifierfichierbdfpatran/

1/6

5/4/2015

*Loadandeditafile.bdf(Patran)[Solved]
Code:

SelectAllViewinaseparatewindow

functionappellepatran()
clc
closeall
clearall

charcode=fopen('caissontreillis.bdf','r');%openthetextfileinmatlab

codepatran=textscan(charcode,'%s\t');%readingthecode
motatrouver='bush_haut';%targetwordsearch
index=find(IsMember(codepatran{1},motatrouver)==1)?%
isempty(index)%?

1
2
3
4
5
6
7
8
9
10
11
12
13

thankyouinadvancePStheattachedfileis*.txtfordownload,considersthatitisa*.bdf,
thankyou

Attachments
caissontreillis.txt(4.7KB,23views)

ReplyWithQuote

#2

07/10/2011,9:10p.m.

Magelan
Moderator

Hello,amethodcouldbetoreadthefilelinebyline,searchingbush_hautifpresent,whether
youmodifythefollowinglines,ifnot,youcopythelineunchangedinthenewfile.Functions
thatcanbeuseful:fgetsstrfind
Joined:
Posts:
Points:

August2007
4464
6383

Forproperusecodetagshere!BasicGuidetoMATLABientraveler:ForumfaqThetutorialsSourcesNatureisabookwritten
inmathematicallanguage.Galilee.

ReplyWithQuote

#3

10/10/2011,0:25

mfontan
NewClub

Joined:
2007
Posts:
Points:

November

Hello,I'maheadofmycodeandInowhangsonalastpoint,sendthemodifiedfilebacktothe
sourceinmatlabfileforuseafter.Ihavetriedthefprintffunctionwithoutsuccessyet..isthis
thegoodfunction?orIdidnothavewellunderstoodmaybe..Igiveyouthecode:

98
29

Code:

SelectAllViewinaseparatewindow

http://www.developpez.net/forums/d1139654/environnementsdeveloppement/matlab/chargermodifierfichierbdfpatran/

2/6

5/4/2015

*Loadandeditafile.bdf(Patran)[Solved]
1
2
3
4
5
6
7
8
9
10
11
12
13

functionappellepatran()
clc
closeall
clearall

%Readingandloadingthesourcefile
charcode=fopen('caissontreillis.bdf','r');%openthetextfileinmatlab
codepatran=textscan(charcode,'%s\t');%readingthecode
codepatran{1};%downloadedfiledisplayforverification
%

Thankyouforyourhelp
ReplyWithQuote

#4

10/10/2011,2:57

Winjerome
ResponsibleC++FAQ

Hello,First,

Theline fprintf(charcode,'%s',codepatran{1,1}), isincorrect:


fprintfdoesnotacceptarraysofinputcells.Thisdiscussioncanhelp.
fprintf(charcode,'%s'); nouse.
Then,thelogiclevelofyourprogram,youcollecteachstringseparatedbytabs,butyoulose
theinformationofthelinebreak.
Finally,yourtwolineswithfprintfwritefollowingthefile,ifyouchoosetheTheoptionto
rewriteeverything(whichseemstobethecase),youmustreturntothebeginningofthefile
(withorFREWINDFSEEK)


Joined:
2009
Posts:
Points:

September
8325
33156
Beforeaskingaquestion,FAQ,Tutorialsandsearchtheforum
?ErrorErrormessagesandwarnings
"Itdoesnotwork"doesnotprovideanyusefulinformationtohelpyou.Clearlyexplainyourproblem(errorswhole,
achieveddesiredresultvs...).
Continuallytryingwefinallysucceed.Somoreitfails,thegreaterthechancethatitworks.JacquesRouxel
ExperienceisthenameeveryonegivestotheirmistakesOscarWilde

Meetmeintheeveningonthechatdeveloppez.comNotechnicalquestionbyMP,Thanks

ReplyWithQuote

#5

10/10/2011,10:10

mfontan
NewClub

Joined:
2007
Posts:
Points:

November
98
29

Hello,thankyouforyourhelpfirst.ThenIhavetheimpressionthatIgrosslymistakeninhow
tohandlemyproblem.iswhatthe"fopen"functionand"textscan"aremostrelevanttomy
problem?textscanprovidesmewithacellcolumninwhichIcanactuallyeasilyworkbut
Winjeromeremarkisjust,Ilosetheinformationlinebreaks...isthatI'mwrongoritis
possibletoanypropertybackinshapeafter?if"textscan"isnottherightoperator,how?
using"fgets"butIdonotunderstandwhathedid...Imapologizeinadvancebutthisisthe
firsttimeIdealswithtextfilesinthiswayandIconfessthattheuseoftheseoperatorsisnew
toI.Youhavetostartonedaythankyouagainforyourpatience!

http://www.developpez.net/forums/d1139654/environnementsdeveloppement/matlab/chargermodifierfichierbdfpatran/

3/6

5/4/2015

*Loadandeditafile.bdf(Patran)[Solved]

ReplyWithQuote

#6

10/10/2011,11:04

mfontan
NewClub

Joined:
2007
Posts:
Points:

Hellotoyou,Ijustfoundanexampleofarelativelysimilarsolutiontomyproblemproposed
byDUTthatrespondswelltomyproblem:

November
98
29

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13

SelectAllViewinaseparatewindow

functionappellepatran()
clc
closeall
clearall

%Readingthefile
fid=fopen('caissontreillis.bdf','r');%openthefileandloading
X=fread(fid,[1,inf]);
fclose(fid);

%%Changeparametersettingstoasearchandreplacementvalue
str='bush_droite';%nameoftheelementtochange

onlycatchinthepartchangingsettings,dependingonthevalues
toreplacethevalues

are

writtenoneachother,forexample:imaginethatthesourcedataoftheform:$Elementsand
ElementPropertiesforregion:bush_droitePBUSH1K210000102+1+10+102.122and
Iwant:$ElementsandElementPropertiesforregion:bush_droitePBUSH1K2.8+2+1
21521000022howtoprogramAutomaticreplacementofthevalueredbythoseingreen
regardlessofthesizeofthesourcevalueandthereplacementvaluewhichmaybedifferent?
thankyou!max

ReplyWithQuote

#7

11/10/2011,9:48

Dut
Editor/Moderator

Hereisacodethatletsyouchangethelinefollowingtheonethatendswithaparticularword
(here"bush_haut"):

Code:

SelectAllViewinaseparatewindow

http://www.developpez.net/forums/d1139654/environnementsdeveloppement/matlab/chargermodifierfichierbdfpatran/

4/6

5/4/2015

*Loadandeditafile.bdf(Patran)[Solved]

R&DEngineerfreelance
Joined:
November
2006
Posts:
18077
Points:
50329

1
2
3
4
5
6
7
8
9
10
11
12
13

X=textread('caissontreillis.bdf','%s','delimiter','\n');

rX=cellfun(fliplr,X'uniformoutput',0);

str='bush_haut';

idx=find(strncmp(rX,fliplr(str),9))+1;

%Changingtheline
%{X}=idx

fid=fopen('caissontreillis2.bdf','wt');
fprintf(fid,'%s\n',X{:});

Butwhyareyoutryingtochangethevalues
i nMATLAB?

IsitnotsimplertodoinPatran?
Whatistheproblemexactly?

Onmyblog:WhenMATLABfprintfanddonotlookinthesamedirection...
MypersonalpagewithmyMATLABcontributions(R2011b/R2014bWindows,LinuxandMac)
andHardware"IwasthebestfriendoldJimhadtheworld.Wehadtochoose.Ithoughtfora
moment,thenIsaid,"ToobadIwillgotohell!'"(SaintHuck)

ReplyWithQuote

#8

12/10/2011,11:04

mfontan
NewClub

Joined:
2007
Posts:
Points:

Hello,thankyouforthecode,cisalreadycleaner.Itrytoiterateinnastran.Patrancreate
.bdf*readbyPatran,buthecannotreadtheeditedfileinmatlab(progtoiterateachieve)so
IreferthesubNatranfile.astherebcptests,allbackbyhandwouldbeachallenge.Itest
andI'mlookinghowtochangemyenntiereonlineandgiveyoucomments.ThanksMax

November
98
29

ReplyWithQuote

#9

12/10/2011,11:24

Dut
Editor/Moderator

Postedbymfontan

astherebcptests,allbackbyhandwouldbeachallenge.

DoyouknowthatPatranhasitsownprogramminglanguagecalledPCL?
Takealookinthedocumentationorat.db.joufilethatcontainsallthePCLcommands
executedduringthePatransession.ItisquitepossibletoautomatePCLPatranNastranBdf
loopwithsuchabatchfile


R&DEngineerfreelance
Joined:
November
2006
Posts:
18077
Points:
50329

Onmyblog:WhenMATLABfprintfanddonotlookinthesamedirection...
MypersonalpagewithmyMATLABcontributions(R2011b/R2014bWindows,LinuxandMac)
andHardware"IwasthebestfriendoldJimhadtheworld.Wehadtochoose.Ithoughtfora

http://www.developpez.net/forums/d1139654/environnementsdeveloppement/matlab/chargermodifierfichierbdfpatran/

5/6

5/4/2015

*Loadandeditafile.bdf(Patran)[Solved]
moment,thenIsaid,"ToobadIwillgotohell!'"(SaintHuck)

ReplyWithQuote

#10

12/10/2011,12:59

mfontan
NewClub

Joined:
2007
Posts:
Points:

Ididnotknow,thankyoufortheinfo,Iwillseethat.Havingalreadydevelopedanownhouse
codeoptimizationinmatlab,Iseekonlytodotheactuallysoftwareinterfaces.justincase,is
whatyouknowadoconthemanagementoftxtfileswithinformationonoperators,mistakes
toavoidetc?Idvouvrethingsalittleandthemajorityofoperatorsarelargelyunknownto
meactually.Pbsolvedforthemoment,thankyoutoallofyou.

November
98
29

ReplyWithQuote

+ReplytoThread
Boardindex

Thisdiscussionisresolved.

DevelopmentEnvironments

MATLAB

*Loadandeditafile.bdf(Patran)[Solved]
I T J OBS

Expertengineerinparallelprogramming
NVIDIAIledeFranceParis(75000)
Dveloppeu(r|se)fullstackSymfony2
CREA2PROCentreMontargis
(M/f)osxdeveloper
AquafadasLanguedocRoussillonMontpellier(34000)
Seemoreoffers

SeethemapofITdeals

CDI
CSD
CDI

PreviousThread|NextThread
Bookmarks
Viadeo
Delicious

Posting
Twitter
MySpace

Google

Facebook

Digg

Yahoo

Youmaynotpostnewthreads
Youmaynotpostreplies
Youmaynotpostattachments
Youcannotedityourposts

activated:yes
TheHTMLcodeis:no

ThevBareenabled:yes
TheSmileysare
enabled:yes
Thetag[IMG]is
activated:yes
Thetag[VIDEO]is

ForumRules
Contactus Developpez.com Archives Top
AlltimesareGMT+2.Thetimenowis2:57.
Copyright20002015www.developpez.comLegalinformation
VolunteerresponsibleforheadingMATLAB:LanaBauerContactbyemail

Developpez.com

Services

Contactus

MATLABForum

Participate

Blogs

LegalInformation

Accommodation

Partners
WebHosting

Copyright20002015www.developpez.com

http://www.developpez.net/forums/d1139654/environnementsdeveloppement/matlab/chargermodifierfichierbdfpatran/

6/6

Potrebbero piacerti anche