excel Input with condition
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Hi everyone,
I'm gonna write an app that needs many inputs. after inserting inputs, some values will be select from some tables with many raws and columns.
for example
if material==copper then Ko=1,K1=2,K3=4 ...
else if material==aluminum then Ko=20,K1=11,K3=-9 ...
else if ...
and so on
what should I do for the best?
채택된 답변
Image Analyst
2015년 11월 12일
0 개 추천
if strcmpi(material, 'copper')
Ko=1;
K1=2;
K3=4;
elseif strcmpi(material, 'aluminum')
Ko=20;
K1=11
K3=-9
end
That's about all we can say with what you gave us. We'd need specifics to provide any more code. There's a lot you can do with MATLAB but unless we know what it is, we can't offer advice other than to look at this link: http://www.mathworks.com/matlabcentral/answers/8026-best-way-s-to-master-matlab
댓글 수: 7
Hamid
2015년 11월 12일
thanks my friend.
my bad I didn't explain well, my final purpose is a code that contains many inputs.
I want my inputs will be an excel file.
for example in the excel file :
material=copper
length=10
width=5
resistivity=200
...
after inserting inputs by the excel file, some values will be select from some tables with many raws and columns(conditions).
I want the tables in another excel file.
for example
if material==copper then Ko=1,K1=2,K3=4 ...
else if material==aluminum then Ko=20,K1=11,K3=-9 ...
else if ...
and so on
What is the way?
Image Analyst
2015년 11월 12일
What is the value of copper? Is it a number? Does it contain a string? If so, what is the string? If it's a string you should not be using == to compare strings. You should use the strcmp() code I gave you.
To put the data into a different file, you need to call xlswrite().
Hamid
2015년 11월 13일
copper is a string.
you are right.
Is there a chance to use directly table excel file in matlab file without call xlswrite()and just creating an excel file??
thanks.
Image Analyst
2015년 11월 13일
How did you assign copper? Did you do this:
copper = 'copper'
or was copper gotten from a table or cell or structure or something? Of course, you know that
material = copper;
and
material = 'copper';
are totally different things, don't you?
Yes, you can use tables as long as each column is of the the same data type. Different columns can be different data types but within a column, they must all be the same type. You can use readtable() and writetable() to read and write tables from and to Excel format .xlsx files.
Hamid
2015년 11월 13일
yes, I know.
copper was gotten from a table and this is what I'm gonna use in my code:
material = copper;
I haven't readtable() in 2009version.
Image Analyst
2015년 11월 13일
Tables did not exist in R2009 either. They only came into existence in R2013b. They're very useful and maybe 6 years is long enough for you to go with an old version - time to upgrade/modernize so you can use the concepts the rest of us are all talking about and using now.
Hamid
2015년 11월 13일
ok, thanks.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Tables에 대해 자세히 알아보기
태그
아직 태그를 입력하지 않았습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
