please help me to correct my program

조회 수: 1 (최근 30일)
Supratik Das
Supratik Das 2019년 3월 23일
댓글: Walter Roberson 2019년 3월 23일
clc;
clear all;
close all;
f1=inputdlg('Enter the value of frequency f1: ');
f2=inputdlg('Enter the value of frequency f2: ');
f3=inputdlg('Enter the value of frequency f3: ');
fm=max(f1,f2);
fm1=max(fm,f3);
fs1=30*fm1;
ts1=1/fs1;
no_of_cycle=4;
t=0:ts1:no_of_cycle*(fs1/fm1)*ts1;
x=sin(2*pi*f1*t)+sin(2*pi*f2*t)+sin(2*pi*f3*t);
Their is a error message
Error using max
Invalid data type. First argument must be numeric or logical.
Error in Ex3
fm=max(f1,f2);
This message shows up when i try to publish the code
Please help me.....

채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 3월 23일
편집: KALYAN ACHARJYA 2019년 3월 23일
f1=str2double(inputdlg('Enter the value of frequency f1: '));
f2=str2double(inputdlg('Enter the value of frequency f2: '));
f3=str2double(inputdlg('Enter the value of frequency f3: '));
fm=max(f1,f2);
fm1=max(fm,f3);
fs1=30*fm1;
ts1=1/fs1;
no_of_cycle=4;
t=0:ts1:no_of_cycle*(fs1/fm1)*ts1;
x=sin(2*pi*f1*t)+sin(2*pi*f2*t)+sin(2*pi*f3*t)
  댓글 수: 2
Supratik Das
Supratik Das 2019년 3월 23일
what changes did u made could u please explain?
Walter Roberson
Walter Roberson 2019년 3월 23일
inputdlg() returns a cell array of character vectors, but your code assumed that inputdlg returned numeric values.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spatial Search에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by