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

6 ビュー (過去 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 Center および File ExchangeEnvironment and Settings についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by