필터 지우기
필터 지우기

I am having trouble with the menu and switch case command because every time I try to get an answer for pressure, I get 5 answers in a matrix instead of one. Does anyone know what I am doing wrong?

조회 수: 2 (최근 30일)
clear all, close all, nfig = 0;
choice = menu('Choose a gas.','Helium Gas','Hydrogen Gas','Oxygen Gas',...
'Chlorine Gas','Carbon Dioxide Gas');
switch choice
case 1
a = 0.0341; b = 0.0237;
case 2
a = 0.244; b = 0.0266;
case 3
a = 1.36; b = 0.0318;
case 4
a = 6.49; b = 0.0562;
case 5
a = 3.59; b = 0.0427;
end
prompt = 'What is the temperature? (C) ';
T = input(prompt)+273;
prompt = 'What is the molar volume? (L/mol) ';
V = input(prompt);
Pressure = VDW(T,V);
prompt = Pressure;

답변 (1개)

Sean de Wolski
Sean de Wolski 2014년 10월 8일
It must be whatever VDW is doing because running everything up to there gives scalar values.
Put a breakpoint in VDW and see what it's doing!
  댓글 수: 3

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by