필터 지우기
필터 지우기

How do I get a dialog box to ask for a variable from out of the workspace?

조회 수: 5 (최근 30일)
René Moerman
René Moerman 2020년 3월 6일
답변: Chidvi Modala 2020년 3월 9일
I want the dialogbox to ask for a variable. Lateron I want to use this input variable for something else.
clear all
close all
clc
S1R2 = csvimport('S1R2.csv'); %measurment position S1R2
S1R3 = csvimport('S1R3.csv'); %measurment position S1R3
prompt = {'Measurement position:','Parameter:'};
dlgtitle = 'Input';
dims = [1 40];
answer = inputdlg(prompt,dlgtitle,dims)
Q = <--- %a variable selected from the answer
T30 = Q(2:end,2); %Variable T30
T30 = cell2mat(T30);
T20 = Q(2:end,4);%Variable T20
T20 = cell2mat(T20);

답변 (1개)

Chidvi Modala
Chidvi Modala 2020년 3월 9일
I assume that you are trying to process the columns of a csv file. Here are a few pointers that may be of help
  • Instead of csvimport, you may use “readtable” function to import data from a CSV file into MATLAB. The “readtable” function automatically detects the header and the number of lines to skip.
T = readtable('myfile.csv');
  • Alternatively, you can specify the number of lines to skip using:
T = readtable('myfile.csv', 'HeaderLines',3); % skips the first three rows of data
  • You can use brace indexing to access the content of the "answer" variable. For instance the following syntax returns the content of the "Parameter" field
p = answer{2};

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by